publicodes
TypeScript icon, indicating that this package has built-in type declarations

1.8.5 • Public • Published

Getting started

npm install publicodes

The library exports a default class Engine which allows you to instantiate an publicodes interpreter with a set of publicodes rules.

import Engine from 'publicodes'
import { parse as parseYaml } from 'yaml'

// We define a list of publicodes rules
const rules = `
dépenses primeur:
  somme:
    - 1.5 kg * 2€/kg    # carottes
    - 500g * 6€/kg      # champignons
    - 3 avocats * 1.5€/avocats
`
const parsedRules = parseYaml(rules)
const engine = new Engine(parsedRules)

const result = engine.evaluate('dépenses primeur')

👉 Continue to the « Getting started » section

Readme

Keywords

none

Package Sidebar

Install

npm i publicodes

Homepage

publi.codes/

Weekly Downloads

1,321

Version

1.8.5

License

MIT

Unpacked Size

1.07 MB

Total Files

8

Last publish

Collaborators

  • johangirod
  • wiinxt
  • clemog
  • emilerolley
  • mquandalle