Network Powering Makers

    jengine-fn

    0.1.60 • Public • Published

    jEngine: fn wercker status

    npm version Bower version Build Status

    MIT License

    global function 'fn' to sandbox all other definitions

    Old Browsers

    it's recomended to add this code before scripts to ensure compatibility with old browsers

    <!--[if lt IE 9]>
        <script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/4.0.5/es5-shim.min.js"></script>
    <![endif]-->
    <!--[if lt IE 12]>
        <script src="//cdnjs.cloudflare.com/ajax/libs/es6-shim/0.21.1/es6-shim.min.js"></script>
    <![endif]-->

    Installation

    npm install jengine-fn --save

    or

    bower install jengine-fn --save

    Usage

    fn.define(moduleName, dependencies?, definition)

    fn.define('moduleName', [ 'dependence_1', 'dependence_2', ..., function ( dependence_1, dependence_1, ...) {
     
        // your code
     
        return definition;
    } ]);

    example

    fn.define('isLargeString', [ '_', function ( _ ) {
     
        function isLargeString (str) {
            return _.isString(str) && str.length > 45;
        }
     
        return isLargeString;
    } ]);

    fn.require(dependencies, callback)

    fn.require(['dependence_1', 'dependence_2'], function ( dependence_1, dependence_1 ) {
     
        // your code
     
    } ]);

    fn.run(dependencies || function)

    or just fn(dependencies || function)

    explicit injection mode

    fn.run(['dependence_1', 'dependence_2', function ( dependence_1, dependence_1 ) {
     
        // your code
     
    } ]);

    implicit injection mode (dependencies will be automatically detected -not recomended when uglifying code- )

    fn.run(function ( dependence_1, dependence_1 ) {
     
        // your code
     
    });

    fn.defer(function, timeout? (0) )

    fn(function () { console.log('test 1'); });
    fn.defer(function () { console.log('test 2'); });
    fn(function () { console.log('test 3'); });

    output:

    test 1
    test 3
    test 2
    

    Keywords

    none

    Install

    npm i jengine-fn

    DownloadsWeekly Downloads

    1

    Version

    0.1.60

    License

    MIT

    Last publish

    Collaborators

    • gsusgz