New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

value-enhancer

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

value-enhancer - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

4

package.json
{
"name": "value-enhancer",
"version": "1.0.0",
"version": "1.0.1",
"private": false,

@@ -42,3 +42,3 @@ "description": "A tiny library to enhance value with reactive wrapper.",

},
"readme": "# value-enhancer\n\n[![Build Status](https://github.com/crimx/value-enhancer/actions/workflows/build.yml/badge.svg)](https://github.com/crimx/value-enhancer/actions/workflows/build.yml)\n[![npm-version](https://img.shields.io/npm/v/value-enhancer.svg)](https://www.npmjs.com/package/value-enhancer)\n[![Coverage Status](https://img.shields.io/coveralls/github/crimx/value-enhancer/master)](https://coveralls.io/github/crimx/value-enhancer?branch=master)\n\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?maxAge=2592000)](http://commitizen.github.io/cz-cli/)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-brightgreen.svg?maxAge=2592000)](https://conventionalcommits.org)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\nA tiny library to enhance value with reactive wrapper.\n\n## Install\n\n```bash\nnpm add value-enhancer\n```\n\n## Why\n\nThe goal of this lib is to bring reactivity to values like MobX but without the implicit-cast magic. It is like RxJS but trimmed and simplified with the focus on value changes instead of async operations which resulted in much smaller codebase.\n\n## Usage\n\n```js\nimport { Val, combine, derive } from \"value-enhancer\";\n\nconst val = new Val(2);\n\nconsole.log(val.value); // 2\n\nval.setValue(3);\nconsole.log(val.value); // 3\n\nval.subscribe(value => console.log(`subscribe: ${value}`)); // subscribe: 3\n\nval.reaction(value => console.log(`reaction: ${value}`)); // (nothing printed)\n\nval.setValue(3); // nothing happened\n\nval.setValue(4); // subscribe: 4, reaction: 4\n\nconst derived = derive(val, value => value * 3);\nconsole.log(derived.value); // 12\nderived.subscribe(value => console.log(`derived: ${value}`)); // derived: 12\n\nconst combined = combine([val, derived], ([val, derived]) => val + derived);\nconsole.log(combined.value); // 16\ncombined.subscribe(value => console.log(`combined: ${value}`)); // combined: 16\n\nval.setValue(5); // subscribe: 5, reaction: 5, derived: 15, combined: 20\n```\n"
"readme": "# value-enhancer\n\n[![Build Status](https://github.com/crimx/value-enhancer/actions/workflows/build.yml/badge.svg)](https://github.com/crimx/value-enhancer/actions/workflows/build.yml)\n[![npm-version](https://img.shields.io/npm/v/value-enhancer.svg)](https://www.npmjs.com/package/value-enhancer)\n[![Coverage Status](https://img.shields.io/coveralls/github/crimx/value-enhancer/master)](https://coveralls.io/github/crimx/value-enhancer?branch=master)\n[![minified-size](https://badgen.net/bundlephobia/minzip/value-enhancer)](hhttps://bundlephobia.com/package/value-enhancer)\n[![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/value-enhancer)](hhttps://bundlephobia.com/package/value-enhancer)\n\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?maxAge=2592000)](http://commitizen.github.io/cz-cli/)\n[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-brightgreen.svg?maxAge=2592000)](https://conventionalcommits.org)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n\nA tiny library to enhance value with reactive wrapper.\n\n## Install\n\n```bash\nnpm add value-enhancer\n```\n\n## Why\n\nThe goal of this lib is to bring reactivity to values like MobX but without the implicit-cast magic. It is like RxJS but trimmed and simplified with the focus on value changes instead of async operations which resulted in much smaller codebase.\n\n## Usage\n\n```js\nimport { Val, combine, derive } from \"value-enhancer\";\n\nconst val = new Val(2);\n\nconsole.log(val.value); // 2\n\nval.setValue(3);\nconsole.log(val.value); // 3\n\nval.subscribe(value => console.log(`subscribe: ${value}`)); // subscribe: 3\n\nval.reaction(value => console.log(`reaction: ${value}`)); // (nothing printed)\n\nval.setValue(3); // nothing happened\n\nval.setValue(4); // subscribe: 4, reaction: 4\n\nconst derived = derive(val, value => value * 3);\nconsole.log(derived.value); // 12\nderived.subscribe(value => console.log(`derived: ${value}`)); // derived: 12\n\nconst combined = combine([val, derived], ([val, derived]) => val + derived);\nconsole.log(combined.value); // 16\ncombined.subscribe(value => console.log(`combined: ${value}`)); // combined: 16\n\nval.setValue(5); // subscribe: 5, reaction: 5, derived: 15, combined: 20\n```\n"
}

@@ -6,2 +6,4 @@ # value-enhancer

[![Coverage Status](https://img.shields.io/coveralls/github/crimx/value-enhancer/master)](https://coveralls.io/github/crimx/value-enhancer?branch=master)
[![minified-size](https://badgen.net/bundlephobia/minzip/value-enhancer)](hhttps://bundlephobia.com/package/value-enhancer)
[![tree-shaking](https://badgen.net/bundlephobia/tree-shaking/value-enhancer)](hhttps://bundlephobia.com/package/value-enhancer)

@@ -8,0 +10,0 @@ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?maxAge=2592000)](http://commitizen.github.io/cz-cli/)

@@ -93,2 +93,7 @@ import { ReadonlyVal } from "./readonly-val";

TValInputs extends readonly ReadonlyVal[] = ReadonlyVal[],
TValue = [...TValInputsValueTuple<TValInputs>],
TMeta = ExtractValMeta<TValInputs[number]>
>(valInputs: readonly [...TValInputs]): CombinedVal<TValInputs, TValue, TMeta>;
export function combine<
TValInputs extends readonly ReadonlyVal[] = ReadonlyVal[],
TValue = any,

@@ -103,2 +108,15 @@ TMeta = ExtractValMeta<TValInputs[number]>

>,
config?: ValConfig<TValue, TMeta>
): CombinedVal<TValInputs, TValue, TMeta>;
export function combine<
TValInputs extends readonly ReadonlyVal[] = ReadonlyVal[],
TValue = any,
TMeta = ExtractValMeta<TValInputs[number]>
>(
valInputs: readonly [...TValInputs],
transform: CombineValTransform<
TValue,
[...TValInputsValueTuple<TValInputs>],
TMeta
> = value => value as TValue,
config: ValConfig<TValue, TMeta> = {}

@@ -105,0 +123,0 @@ ): CombinedVal<TValInputs, TValue, TMeta> {

@@ -48,4 +48,13 @@ import { ReadonlyVal } from "./readonly-val";

export function derive<TSrcValue = any, TValue = any, TMeta = any>(
val: ReadonlyVal<TSrcValue>
): DerivedVal<TSrcValue, TValue, TMeta>;
export function derive<TSrcValue = any, TValue = any, TMeta = any>(
val: ReadonlyVal<TSrcValue>,
transform: ValTransform<TSrcValue, TValue>,
config?: ValConfig<TValue, TMeta>
): DerivedVal<TSrcValue, TValue, TMeta>;
export function derive<TSrcValue = any, TValue = any, TMeta = any>(
val: ReadonlyVal<TSrcValue>,
transform: ValTransform<TSrcValue, TValue> = value =>
value as unknown as TValue,
config: ValConfig<TValue, TMeta> = {}

@@ -52,0 +61,0 @@ ): DerivedVal<TSrcValue, TValue, TMeta> {

@@ -43,2 +43,5 @@ /* eslint-disable @typescript-eslint/ban-types */

/**
* Loop through a config object and `bindInstance` each val to the instance.
*/
export function withValueEnhancer<TInstance, TConfig extends ValEnhancerConfig>(

@@ -58,2 +61,5 @@ instance: TInstance,

/**
* @returns curried function of `bindInstance`
*/
export function createInstanceBinder<TInstance>(instance: TInstance): BindVal {

@@ -67,2 +73,10 @@ const bindVal: BindVal = (key, val) => {

/**
* Bind a Val to a property of an instance.
* `bindInstance(Obj, "aKey", val)` results in:
* - `Obj.aKey`, value of `val.value`
* - `Obj.setAKey(value)`
* - `Obj._aKey$`, the `val`
* @returns Same instance with bound properties
*/
export function bindInstance<TInstance, TKey extends string, TValue, TMeta>(

@@ -69,0 +83,0 @@ instance: TInstance,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc