time-to-botec/js/node_modules/@stdlib/utils/define-nonenumerable-write-only-accessor
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

Non-Enumerable Write-Only Accessor

Define a non-enumerable write-only accessor.

Usage

var setNonEnumerableWriteOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-write-only-accessor' );

setNonEnumerableWriteOnlyAccessor( obj, prop, setter )

Defines a non-enumerable write-only accessor.

var obj = {};
var val = '';

function setter( v ) {
    val = v;
}

setNonEnumerableWriteOnlyAccessor( obj, 'foo', setter );

obj.foo = 'boop';

var bool = ( val === 'boop' );
// returns true

Notes

  • Non-enumerable write-only accessors are non-configurable.

Examples

var setNonEnumerableWriteOnlyAccessor = require( '@stdlib/utils/define-nonenumerable-write-only-accessor' );

function Foo( secret ) {
    if ( !(this instanceof Foo) ) {
        return new Foo( secret );
    }
    setNonEnumerableWriteOnlyAccessor( this, 'secret', setter );
    return this;

    function setter( v ) {
        secret = v;
    }
}

var foo = new Foo( 'beep' );

foo.secret = 'boop';