Needless Patchouli Manufacture

    big-bang

    0.9.1 • Public • Published

    js3

    javaScript-stand-supplement

    Usage

    var js3 = require('js3');
    var typeOf=js3.typeOf;
    var extend=js3.extend;
    var queryParse=js3.queryParse;
     
    // typeOf
    console.log(typeOf([]));   // array
    console.log(typeOf(null)); // null
    console.log(typeOf({}));   // object
    console.log(typeOf(1));    // number
    console.log(typeOf('hi')); // string
    console.log(typeOf(true)); // boolean
    console.log(typeOf(function(){})); // function
     
    // typeOf plus mode
    console.log(typeOf(NaN,true));             // nan
    console.log(typeOf(new Date(),true));      // date
    console.log(typeOf(new RegExp(),true));    // regexp
    console.log(typeOf(new Error(),true));     // error
    console.log(typeOf(new Map(),true));       // map
    console.log(typeOf(new Set(),true));       // set
    console.log(typeOf(document.body,true));   // htmlbodyelement
     
     
    // extend
    console.log( extend({a:1},{a:2,b:2}) === {a:2,b:2} )
    console.log( extend({a:1},{a:2,b:2},{a:3,c:3}) === {a:3,b:2,c:3} )
     
    console.log( extend({a:1},{a:2,b:2},false) === {a:1,b:2} )
    console.log (extend({a:1},{a:2,b:2},{a:3,b:3,c:3},false) === {a:1,b:2,c:3} )
     
    // queryParse
    console.log(queryParse()); // location: http://eg.com?a=1&b=2  =>  {a:'1',b:'2'}
    console.log(queryParse('custom=u&time=now'));    // {custom:'u',time:'now'}
    console.log(queryParse({custom:'u',time:'now'}));// 'custom=u&time=now'
    console.log(queryParse(null));         // empty object
    console.log(queryParse(undefined));    // empty object
    console.log(queryParse('hello word')); // empty object
     

    Installation

    With npm do

    $ npm install js3

    With component do

    License

    (MIT)

    Copyright (c) 2013 Evan Tsword Yao <yaoyifeng@hisign.com.cn>

    Keywords

    Install

    npm i big-bang

    DownloadsWeekly Downloads

    2

    Version

    0.9.1

    License

    MIT

    Last publish

    Collaborators

    • tswordyao