# abstract-value

> Basic value abstraction of any kind

Latest version **2.0.2** (published 2016-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install abstract-value
pnpm add abstract-value
yarn add abstract-value
bun add abstract-value
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2016-10-11 |
| First published | 2016-04-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | KROT47 |
| Maintainers | krot47 |

## Links

- npm: https://www.npmjs.com/package/abstract-value
- Repository: https://github.com/KROT47/abstract-value
- Homepage: https://github.com/KROT47/abstract-value#readme
- Issues: https://github.com/KROT47/abstract-value/issues
- npm.io page: https://npm.io/package/abstract-value

## Recent versions

- 2.0.2 (latest) — 2016-10-11
- 2.0.1 — 2016-07-13
- 1.0.4 — 2016-04-09
- 1.0.3 — 2016-04-02
- 1.0.2 — 2016-04-02
- 1.0.1 — 2016-04-02
- 1.0.0 — 2016-04-02

## README

# Abstract-Value

Is used as helper to define any kind of value as abstract value type.  
Also allows to add any properties to values, even to String and Number.


```js
const Value = require( 'abstract-value' )( 'Value' );

var values = [
    123,
    '123',
    Value( 123, { add: 456 } ),
    Value( '123', { changeTo: '456' } ),
    Value( [ 123, 789 ] )
];

for ( var i = 0; i < values.length; ++i ) {
    
    if ( values[ i ] instanceof Value ) {
        // change value
        if ( values[ i ].changeTo ) values[ i ].set( values[ i ].changeTo );
        // operation on value
        if ( values[ i ].add ) values[ i ] += values[ i ].add;
        // get value
        console.log( values[ i ].valueOf() );
    } else {
        console.log( values[ i ] );
    }
}

Output:
123
"123"
579
"456"
Array [123, 789]
```

Also you can chain some methods ( "set", "setProperties" ):

```js
const Value = require( 'abstract-value' )( 'Value' );

var val = Value( 123 );

console.log( val );
console.log( val.set( 124 ).valueOf() );
console.log( val.setProperties({ t: 1 }).t );

Output:
Value {__value: 123}
124
1
```

---
_Source: https://npm.io/package/abstract-value · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
