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

    symbol.prototype.description

    1.0.4 • Public • Published

    Symbol.prototype.description Version Badge

    dependency status dev dependency status License Downloads

    npm badge

    An ECMAScript spec-compliant Symbol.prototype.description shim. Invoke its "shim" method to shim Symbol.prototype.description if it is unavailable. Note: Symbol#description requires a true ES6 environment, specifically one with native Symbols.

    This package implements the es-shim API interface. It works in an ES6-supported environment and complies with the spec.

    Most common usage:

    var description = require('symbol.prototype.description');
    
    assert(description(Symbol('foo')) === 'foo');
    assert(description(Symbol()) === undefined);
    assert(description(Symbol(undefined)) === undefined);
    assert(description(Symbol(null)) === 'null');
    
    // note: this should be the empty string, but in many engines,
    // it is impossible to distinguish Symbol() and Symbol('')
    // without globally replacing `Symbol`
    assert(description(Symbol('')) === undefined);
    
    if (!Symbol.prototype.description) {
    	description.shim();
    }
    
    assert(description(Symbol('foo')) === Symbol('foo').description);
    assert(description(Symbol()) === Symbol().description);
    assert(description(Symbol(undefined)) === Symbol(undefined).description);
    assert(description(Symbol(null)) === Symbol(null).description);
    
    assert(Symbol('').description === ''); // this works fine!

    Tests

    Simply clone the repo, npm install, and run npm test

    Install

    npm i symbol.prototype.description

    DownloadsWeekly Downloads

    2,216,873

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    24.1 kB

    Total Files

    18

    Last publish

    Collaborators

    • avatar