Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-chr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-chr

Babel plugin that precompiles CHR.js source code

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

babel-plugin-chr

Babel plugin that precompiles CHR.js source code.

Install

npm install babel-plugin-chr

Usage

Run:

babel --plugins chr script.js

Or add the plugin to your .babelrc configuration:

{
  "plugins": [ "chr" ]
}

Example

The plugin will compile the following code:

var CHR = require('chr')
var chr = new CHR()

chr('some @ a ==> b')

into:

var _Runtime = require('chr/runtime');
var chr = {
  Store: new _Runtime.Store(),
  History: new _Runtime.History(),
  Constraints: {},
  Replacements: []
};

chr = (function (chr) {
  chr.a = _Runtime.Helper.dynamicCaller('a');
  chr.Constraints['a/0'] = [];
  chr.b = _Runtime.Helper.dynamicCaller('b');
  chr.Constraints['b/0'] = [];

  chr.Constraints['a/0'][0] = function (constraint) {
    var self = this;
    var ids = [constraint.id];

    if (ids.every(function (id) {
      return self.Store.alive(id);
    })) {
      if (_Runtime.Helper.allDifferent(ids)) {
        if (self.History.notIn('some', ids)) {
          self.History.add('some', ids);
          self.b();
        }
      }
    }
  };

  return chr;
})(chr);

It supports the normal CHR.js syntax as specified here: fnogatz/CHR.js

Keywords

FAQs

Package last updated on 20 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc