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

factor-in

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

factor-in

A factory of factory functions. Share and extend object data.

  • 1.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
increased by1200%
Maintainers
1
Weekly downloads
 
Created
Source

factor-in

NPM version build status Test coverage js-standard-style

A factory of factory functions. Share and extend object data.

Install

$ npm install --save factor-in

Usage

import factorIn from 'factor-in'

// Create our base object data we expect all
// factory functions to inherit from.
const f = factorIn ({
  foo () {},
  bar () {}
})

var obj = f ({ baz: 'Baz', qux: 'Qux' })
//=> {foo: foo(), bar: bar(), baz: 'Baz', qux: 'Qux'}
test('Demo component', nest => {
  // fixture to be shared across nested tests
  const fixture = factorIn({
    setWord () {},
    setMode () {}
  })

  nest.test('...with basic fixture', t => {
    const el = <Hello actions={ fixture() } />
    //> { setWord: function setWord () {}, setMode: function setMode () {} }
    t.equal(actual, expected, 'should have common methods')
    t.end()
  })

  nest.test('...with extended fixture', t => {
    const extendedFixture = fixture({ setAction () {} })
    const el = <Hello actions={ extendedFixture } />
    //> { setWord: function setWord () {}, setMode: function setMode() {}, setAction: function setAction() {} }
    t.equal(actual, expected, 'should have common and extended methods')
    t.end()
  })
})

License

MIT © Chris Buttery

Keywords

FAQs

Package last updated on 27 Oct 2015

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