js-stand
v2.0.0
Published
javaScript-stand-supplement
Downloads
13
Maintainers
Readme
js-stand
javaScript-stand-supplement
Usage
var js = require('js-stand');
var typeOf=js.typeOf;
var queryParse=js.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
// 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 js-stand
Then bundle for the browser with browserify.
With component do
License
(MIT)
Copyright (c) 2013 Evan Tsword Yao <[email protected]>