Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    in-jspublic

    in-js

    in-js is a sweet.js macro for JavaScript which adds a keyword, in?, to the language.

    Examples

    The file examples.js in this repo contains a few examples. To run that file, run make run-examples in the root of this repo.

    var x = 1, y = [1, 2, 3];
     
    if (in? y) {
      console.log("1 is in the list [1, 2, 3]");
    }
     
    // 1 is in the list [1, 2, 3] 
    var frameworks = [
      {language: "ruby", "name": "rails"},
      {language: "clojure", name: "compojure"},
      {language: "javascript", name: "koa"},
      {language: "python", name: "django"},
    ];
     
    var filtered = frameworks.filter(function(framework){
      return framework.language in? ['ruby', 'javascript'];
    });
     
    console.log(filtered);
     
    /*
    [ { language: 'ruby', name: 'rails' },
      { language: 'javascript', name: 'koa' } ]
    */

    Tests

    make test

    License

    MIT

    Keywords

    none

    install

    npm i in-js

    Downloadslast 7 days

    5

    version

    0.1.2

    license

    none

    last publish

    collaborators

    • avatar