@actualwave/closure-value

    0.0.3 • Public • Published

    Closure Value

    Factory functions to create a value storage hidden in a closure

    • valueFactory() - creates storage for a single value
    • valuesMapFactory() - creates storage with Map hidden, allows adding key/value pairs
    • valuesSetFactory() - creates storage with Set hidden, allows adding unique values

    Demo on jsFiddle

    valueFactory()

    Returns object with methods

    • get() - retrieve current value
    • set(value) - store value

    valuesMapFactory()

    Returns object with methods

    • getDefault() - retrieve Map with default values
    • copy() - retrieve a copy of the Map with all currently stored values
    • delete(key) - delete value by key
    • has(key) - check if value exists by key
    • set(key, value) - store value by key
    • get(key) - retrieve value by key Additionaly to methods returned object contains values field with Map object used for storing values.

    valuesSetFactory()

    Returns object with methods

    • getDefault() - retrieve Set with default values
    • get() - retrieve a copy of Set with currently stored values
    • delete(value) - remove value from Set
    • has(value) - check if Set contains value
    • add(value) - add value to Set Additionaly to methods returned object contains values field with Set object used for storing values.

    Install

    npm i @actualwave/closure-value

    DownloadsWeekly Downloads

    0

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    5.18 kB

    Total Files

    4

    Last publish

    Collaborators

    • actualwave