1.1.1 • Published 10 months ago

togglee v1.1.1

Weekly downloads
17
License
APACHE-2.0
Repository
github
Last release
10 months ago

toggle_logo_text

Build & Publish codecov npm GitHub license Maintenance Donate

Motivation

Simple library to separate deployment of features from release time. It uses network accesible files without the need of a server to provide feature toggles.

Installation

add it to your project using npm install togglee --save or yarn add togglee

Usage

import { Togglee } from '../lib'
// or: const { Togglee } = require("togglee")

const url = "https://gist.githubusercontent.com/alvarolorentedev/c469f99bef5a5c0634b4a94a4acd6546/raw/toggles"
const refreshRateSeconds = 5
const defaultValues = [
    {
      type: "release",
      name: "prop",
      value: true,
    },
    {
      type: "release",
      name: "prop2",
      value: true
    },
    {
      type: "context",
      name: "prop3",
      conditions: [
        {
          field: "username",
          value: "user1",
          operation: "eq"
        }
      ]
    }
]

const subject = new Togglee(url, refreshRateSeconds, defaultValues)


setInterval(() => {
    if (subject.isEnabled("prop"))
        console.log("do stuff")
    else
        console.log("dont do stuff")
    if (subject.isEnabled("prop3", {"username": "user1"}))
        console.log("do stuff for user 1")
    else
        console.log("dont do stuff for user 1")
    if (subject.isEnabled("prop3", {"username": "user2"}))
        console.log("do stuff for user 2")
    else
        console.log("dont do stuff for user 2")
        
    console.log("-----------")
}, 10000);

Type of toggles

Release

Simple true/false logical path definition.

{
    type: "release",
    name: "prop",
    value: true,
}

Context

Allows complex logic to decide the outcome of the logical path (example traffic, users, resources available).

{
    type: "context",
    name: "prop3",
    conditions: [
        {
            field: "username",
            value: "user1",
            operation: "eq"
        }
    ]
}

available operations are:

  • 'eq': equal (===)
  • 'ne': not equal (!==)
  • 'gt': greater than (>)
  • 'ge': greater equal (>=)
  • 'lt': lesser than (<)
  • 'le': lesser qqual (<=)
1.1.1

10 months ago

1.1.0

10 months ago

1.0.39

2 years ago

1.0.40

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.49

2 years ago

1.0.51

2 years ago

1.0.50

2 years ago

1.0.53

2 years ago

1.0.52

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.38

2 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.24

2 years ago

1.0.23

3 years ago

1.0.11

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.10

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.0.19

3 years ago

0.0.18

4 years ago

0.0.17

5 years ago

0.0.15

5 years ago

0.0.14

5 years ago

0.0.13

5 years ago

0.0.12

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago