be-type is based on ECMAScript2015+ proxy feature
yarn add be-type
npm install --save be-typeJavaScript:
import be from 'be-type';
be.function(()=>{}); // trueCustom type check:
//be.js
import be,{setBe} from 'be-type';
export default setBe({
    Negative:(value)=> be.Number(negative) && negative < 0
})
//other.js
import be from '../be.js';
be.Negative(-1); // true- If the first letter of the API is lowercase, then it refers to toString.call(value), the type returned by call.
 
be.function(()=>{})
equivalenttoString.call(()=>{}) ==== "[object Function]"
be.generatorFunction(function* (){})
equivalenttoString.call(function* (){}) ==== "[object GeneratorFunction]"
be.uint8Array(new Uint8Array())
equivalenttoString.call(new Uint8Array()) ==== "[object Uint8Array]" etc..
- if the first letter of the API is Uppercase, it means not toString.call(value), Custom type returned by call
 
| Interface | Spec | 
|---|---|
| Function | plain function | 
| Object | plain object | 
| String | basic string | 
| Number | basic number | 
| Boolean | basic boolean | 
| NaN | strict equality to NaN | 
| Nil | null or undefined | 
| Empty | none length | 
| Infinity | strict equality to Infinity | 
| Finite | basic number and not NaN or Infinity | 
| Native | pristine native function | 
| SafeInteger | based on Number.isSafeInteger | 
| Integer | based on Number.isInteger | 
| Element | HTML Element |