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

    sandjspublic

    Sand.js

    JS Sandboxing made easy, lightweight module manager for JavaScript.

    Introduction

    Sand.js is a part of the fjs project. Sand.js is a module manager that would fullfill the following requirements :

    sand.define

    In myProject/first.js (by convention)

    sand.define("myProject/first", function(r) {
      
      console.log("Execute first");
      
      return {
        foo : "bar"
      };
    });
    

    In myProject/second.js (by convention)

    sand.define("myProject/second", ["myProject/first"], function(r) {
      
      console.log("Execute second");
      
      return function(){
      
        console.log("Hello World");
        
        return {
          first : r.first,
          foo2 : "bar2"
        };
      };
    });
    

    sand.require

    Basic

    //in main.js
    
    // we require it by name
    sand.require("myProject/first");
    //=> Execute first
    
    // we require first by name and we use it in a callback function
    sand.require("myProject/first", function(r) {
      console.log(r.first);
    });
    //=> Execute first
    //=> { foo : "bar" };
    

    Recursively

    // folder/* require all the files in a folder
    sand.require("myProject/*", function(r) {
      console.log(r.myProject);
      console.log(r.myProject.second());
    });
    //=> Execute first
    //=> Execute second
    //=> { first : { "foo" : "bar"}, second : [Function] }
    //=> { first : { "foo" : "bar"}, foo2 : "bar2" }
    

    With alias

    // we require first by name and we use it in a callback function
    sand.require("myProject/first->aliasName", function(r) {
      console.log(r.aliasName);
    });
    //=> Execute first
    //=> { foo : "bar" };
    

    Contribute

    Add an issue if you find bugs or please

    • Fork me
    • Add your tests
    • Make your contribution
    • Pass all the tests
    • Add a pull request

    Librairies

    To add a librairie to sandjs, fork the librairy, and scope it into a sandjs format. To add it to the list, send us an email at fjsproject[at]gmail.com..

    Keywords

    none

    install

    npm i sandjs

    Downloadsweekly downloads

    3

    version

    0.0.2

    license

    none

    repository

    githubgithub

    last publish

    collaborators

    • avatar