New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

be-type

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

be-type

be-type is based on ECMAScript2015+ proxy feature

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

be-type

be-type is based on ECMAScript2015+ proxy feature

Travis Coverage Status npm npm npm

Usage

yarn add be-type
npm install --save be-type

JavaScript:

import be from 'be-type';
be.function(()=>{}); // true

Custom 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

API

Interface Rule:

  • If the first letter of the API is lowercase, then it refers to toString.call(value), the type returned by call.

be.function(()=>{}) equivalent toString.call(()=>{}) ==== "[object Function]"

be.generatorFunction(function* (){}) equivalent toString.call(function* (){}) ==== "[object GeneratorFunction]"

be.uint8Array(new Uint8Array()) equivalent toString.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

Default built-in type check:

InterfaceSpec
Functionplain function
Objectplain object
Stringbasic string
Numberbasic number
Booleanbasic boolean
NaNstrict equality to NaN
Nilnull or undefined
Emptynone length
Infinitystrict equality to Infinity
Finitebasic number and not NaN or Infinity
Nativepristine native function
SafeIntegerbased on Number.isSafeInteger
Integerbased on Number.isInteger
ElementHTML Element

Keywords

type

FAQs

Package last updated on 28 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts