1.4.0 • Published 10 months ago

tggl-core v1.4.0

Weekly downloads
-
License
ISC
Repository
github
Last release
10 months ago

Usage

This library is not intended for direct use, you probably want to use the client instead. The client nicely wraps this library in a more convenient way.

If you still want to use this library directly, you can add the package to your dependencies:

npm i tggl-core

And start evaluating flags:

import { evalFlag, Flag, Operator } from 'tggl-core'

const flag: Flag = {
  conditions: [
    {
      rules: [
        {
          key: 'email',
          operator: Operator.StrEndsWith,
          values: ['@acme.com'],
          negate: false,
        }
      ],
      variation: {
        active: true,
        value: 'foo'
      }
    },
  ],
  defaultVariation: {
    active: false,
    value: null,
  },
}

const result = evalFlag(
  {
    userId: 'abc',
    email: 'john.doe@acme.com'
  },
  flag
)

console.log(result) // => 'foo'

Porting it to another language

If you are porting it to another language, copy standard_tests.json and write a single unit tests that iterates over all the examples of this file. This is exactly what standard.test.ts does.

1.4.0

10 months ago

1.3.0

10 months ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago