Have ideas to improve npm?Join in the discussion! »

    @silen/is-promise
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    is-promise

    Determine if a value is Promise

    install

    npm i @silen/is-promise
    

    api

    • declare function isPromise(val: any): boolean;

    usage

    const { isPromise } = require('@silen/is-promise');
    // or
    import { isPromise } from '@silen/is-promise';
     
    console.log(isPromise(new Buffer(4)));
    console.log(isPromise(Buffer.alloc(4)));
    console.log(isPromise(undefined));
    console.log(isPromise(null));
    console.log(isPromise(''));
    console.log(isPromise(true));
    console.log(isPromise(0));
    console.log(isPromise(1));
    console.log(isPromise(1.0));
    console.log(isPromise('string'));
    console.log(isPromise({}));
    console.log(isPromise(function foo() {}));
    console.log(isPromise(Symbol()));
    console.log(isPromise(new Set));
    console.log(isPromise(new Map));
    console.log(isPromise(new WeakMap));
    console.log(isPromise(new WeakSet));
     
    // or
    console.log(window.Type.isPromise(new WeakSet));

    This is a demo for testing the usage of isPromise from @silen/is-promise module. You can try the others and do likewise.

    others

    Install

    npm i @silen/is-promise

    DownloadsWeekly Downloads

    0

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    8.24 kB

    Total Files

    9

    Last publish

    Collaborators

    • avatar