Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stamp/arg-over-prop

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stamp/arg-over-prop

Assign properties passed to the stamp factory

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
142
decreased by-22.4%
Maintainers
1
Weekly downloads
 
Created
Source

@stamp/arg-over-prop

Assign properties passed to the stamp factory

Usage

import ArgOverProp from '@stamp/arg-over-prop';

const StampA = compose({
    properties: {
        foo: 1
    }
})
.compose(ArgOverProp).argOverProp('foo');

const instance1 = StampA(); // { foo: 1 }
const instance2 = StampA({ foo: 999 }); // { foo: 999 }

A shorter but identical version of the same StampA:

const StampA = ArgOverProp.argOverProp({foo: 1});

Basically, the arg-over-prop stamp sets properties in an initializer. The code below is what the StampA becomes.

const StampA = compose({
    properties: {
        foo: 1
    },
    initializers: [function (opts) {
        this.foo = opts.foo;
    }]
})

Example

import ArgOverProp from '@stamp/arg-over-prop';

const HasColor = ArgOverProp.argOverProp('color', 'background');
const HasPoint = ArgOverProp.argOverProp({ x: 0, y: 0 });

const ColorPoint = compose(HasColor, HasPoint);

const point = ColorPoint({ color: 'blue', x: 15 });

console.log(point.color); // "blue"
console.log(point.background); // undefined
console.log(point.x); // 15
console.log(point.y); // 0

FAQs

Package last updated on 29 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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