Skip to content

Files

Latest commit

29619d3 · Sep 25, 2020

History

History
659 lines (419 loc) · 11 KB

API.md

File metadata and controls

659 lines (419 loc) · 11 KB

is

executor of checks to delegate a data for checking have a ability use upper case when string annotation name checks used

Parameters

  • check String it can be name of branch/check
  • null-null any it can be name of branch/check

Examples

// the same
is('platform', 'browser');
is.platform('browser');
is.platform.browser();

Returns Boolean

is.typeof

typeof return name of the data type it can return all 10 data types plus new data types of ES6.

Parameters

  • data any

Examples

is.typeof([]);      // => 'array'
is('typeof', []);   // => 'array'

Returns String

is.nan

It determine only NaN

Parameters

  • data any

Examples

is.nan(NaN);        // => true
is('NaN', NaN);     // => true
is('NaN', 'NaN');   // => false

Returns Boolean

is.infinity

It determine only infinity's

Parameters

  • data any

Examples

is.infinity(-Infinity);                     // => true
is('Infinity', Infinity);                   // => true
is('Infinity', 9999999*9999999*9999999);    // => true

Returns Boolean

is.null

It determine only null

Parameters

  • data any

Examples

is.null(null);      // => true
is('null', null);   // => true
// otherwise false

Returns Boolean

is.number

It determine only numbers (like a native typeof)

Parameters

  • data any

Examples

is.number(1);         // => true
is.number(NaN);       // => true
is('number', null);   // => false

Returns Boolean

is.string

It determine only strings

Parameters

  • data any

Examples

is.string('');          // => true
is('string', 'null');   // => true
is('string', []);       // => false

Returns Boolean

is.boolean

It determine only booleans

Parameters

  • data any

Examples

is.boolean(true);          // => true
is('boolean', false);      // => true
// otherwise false

Returns Boolean

is.function

It determine only functions

Parameters

  • data any

Examples

is.function(Function);      // => true
is('function', Function);   // => true

Returns Boolean

is.array

It determine only array

Parameters

  • data any

Examples

is.array([]);           // => true
is('array', [1,2]);     // => true
is('array', '1,2');     // => false

Returns Boolean

is.object

It determine only objects. Except null and array

Parameters

  • data any

Examples

is.object({});          // => true
is('object', {x:1});    // => true
is('object', []);       // => false
is('object', null);     // => false

Returns Boolean

is.undefined

It determine only undefined

Parameters

  • data any

Examples

is.undefined(undefined);    // => true
is('undefined', void(0));   // => true

Returns Boolean

is.defined

always success except undefined

Parameters

  • data any

Examples

is.defined(null);       // => true
is('defined', 0);       // => true
is('defined', void(0)); // => false

Returns Boolean

is._object

  • **See: is.object less specific determine **

It determine only objects of customers (developers)

Parameters

  • data any

Examples

is._object({});                     // => true
is('_object', {x:1});               // => true
is('_object', new (class q {}));    // => true
is('_object', null);                // => false
is('_object', new Date);            // => false
is('_object', new Error);           // => false

Returns Boolean

is._number

strictly determine of numbers. Not NaN or Infinity or NUMBER more than possible to consider

Parameters

  • data any

Examples

is._number(1);         // => true
is._number(NaN);       // => false
is('_number', null);   // => false
is('_number', 9999999*9999999*9999999);   // => false

Returns Boolean

is.class

It determine classes.

Parameters

  • data any

Examples

class q {}
class q1 extends q {}
function Class (){}
is.class( Class );      // => false
is.class( q );          // => true
is('Class', q1 );       // => true

Returns Boolean

is._equal

  • **See: is.equal less specific determine **

strict comparison to equivalent between arguments

* circular structure cannot be equaled. It returns false

Parameters

  • first any
  • second any

Examples

is('_equal', [1,{x:2}],[1,{x:1}]);  // => false
is('_equal', [1,{x: Function}],[1,{x:function(){}}]);// => false
is('_equal', [1,{x:'1'}],[1,{x:1}]);// => false
is('_equal', [1,{x:1}],[1,{x:1}]);  // => true
is._equal();                        // => true becose (undefined, undefined)
is._equal(NaN, NaN);                // => true

Returns Boolean

is.equal

  • **See: is._equal more specific determine **

comparison to equivalent between arguments ignores difference in functions ignores data types difference if it equivalent (1,'1')

* circular structure cannot be equaled. It returns false

Parameters

  • first any
  • second any

Examples

is('equal', [1,{x:2}],[1,{x:1}]);  // => false
is('equal', [1,{x:'1'}],[1,{x:1}]);// => true
is('equal', [1,{x:1}],[1,{x:1}]);  // => true
is.equal();                        // => true becose (undefined, undefined)
is.equal(NaN, NaN);                // => true
is('equal', [1,{x: Function}],[1,{x:function(){}}]);// => true

Returns Boolean

is.empty

check the data that may contain child elements. Otherwise returns false.

* can work not safe and throws an error when data is incorrect.

Parameters

  • data any
  • notSafe Boolean without "notSafe" can check any data type (optional, default false)

Examples

is.empty([]);        // true
is('empty', '');     // true
is('empty', {});     // true
is.empty([1]);       // false
is('empty', '[]');   // false

Returns Boolean

is.finite

It determine only numbers of possible to consider

Parameters

  • data any

Examples

is.finite(1);         // => true
is.finite(NaN);       // => false
is('finite', null);   // => false
is('finite', 9999999*9999999*9999999);   // => false

Returns Boolean

is.countable

It determine value can be involved in mathematical operations

Parameters

  • data any

Examples

is.countable(1);         // => true
is.countable('1');       // => true
is.countable(true);      // => true
is.countable(NaN);       // => false
is('countable', null);   // => false
is('countable', 9999999*9999999*9999999);   // => false

Returns Boolean

is.date

It determine object of native Date ( some things like (new Date()) instanceof Date )

Parameters

  • data any

Examples

is.date(new Date);      // => true
is('date', new Date);   // => true

Returns Boolean

is.error

It determine object of error

Parameters

  • data any

Examples

is.error(new Error);        // => true
is('error', new TypeError); // => true

Returns Boolean

is.regexp

It determine RegExp.

Parameters

  • data any

Examples

is.regexp(new RegExp);  // => true
is('RegExp', /1/g);     // => true
is('regexp', '/1/g');   // => false because it isn't RegExp

Returns Boolean

is.argument

It determine object arguments.

Parameters

  • data any

Examples

var args; // get object arguments
(function(){ args = arguments; })();
is.argument(args);          // => true
is('argument', args);       // => true
is('argument', []);         // => false

Returns Boolean

is.symbol

It determine instance Symbol. (safety for es5)

Parameters

  • data any

Examples

is.symbol(Symbol());     // => true
is('symbol', Symbol());  // => true

Returns Boolean

is.promise

It determine instance Promise.

Parameters

  • data any

Examples

is.promise(new Promise(function(){}));  // => true
is('promise', q.defer().promise);       // => true
is('promise', {then: function(){}});    // => true

Returns Boolean

is.support.symbol

It determine platform support for Symbol (save)

Examples

is('support', 'symbol');
is.support('symbol');
is.support.symbol();

Returns Boolean

is.support.promise

It determine platform support for Promise (save)

Examples

is('support', 'promise');
is.support('promise');
is.support.promise();

Returns Boolean

is.platform.node

It determine platform Node.js (save)

Examples

is('platform', 'node'); // => true
is.platform('node');    // => true
is.platform.node();     // => true

Returns Boolean

is.platform.browser

It determine platform browser (save)

Examples

is('platform', 'browser'); // => true
is.platform('browser');    // => true
is.platform.browser();     // => true

Returns Boolean

exports

defination on platforms (both variants on platform like Electron)

bower install --save s-is

npm install --save s-is

Examples

window.is                   // in browser
var is = require('s-is')    // in Node.js