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

fixd

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

fixd

Test fixture utility

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Travis Codecov

Fixd

Fixd is a JavaScript library for creating reference-free, immutable (frozen) objects. It supports immutability on all native types, including deeply nested objects and arrays.

The use-case Fixd was built around is "locking" reusable fixtures to prevent mutations, an in-turn, side-effects during testing.

Installation

npm i fixd --save

Quick Start

'use strict'
const fixd = require('fixd')

// Add a new object
fixd.foo = { 
  fizz: 'buzz', 
  baz: { 
    quz: 'baz' 
  } 
}

// Access object
fixd.foo // -> { fizz: 'buzz', baz: { quz: 'baz' } }

// Throws error, prevents mutations
foo.fizz = 'bazz' // -> ERROR: Cannot assign to read only property

Note: While Object.freeze will prevent modifications, use strict must be applied to the document in order to throw an error on attempted mutation.

Creating New Instances

Because the objects are frozen, Fixd provides the create method for returning a new, modified instance.

fixd.create('foo', (foo) => {
  foo.fizz = 'bazz'
  return foo
}) // -> { fizz: 'bazz', baz: { quz: 'baz' } }

The above will not modify the foo object, it will return a new, reference-free, frozen instance of the object based on the modification performed in the callback.

Development

The prefered dependency manager for Fixd is Yarn. To run tests, execute the following after dependencies have been installed:

yarn test

License

Fixd is developed and maintained by TechnologyAdvice and released under the ISC license.

Keywords

FAQs

Package last updated on 26 Jun 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