Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/outsystems/immutable-records
A simple implementation of immutable records.
https://github.com/outsystems/immutable-records
engineering snyk-product
Last synced: about 2 months ago
JSON representation
A simple implementation of immutable records.
- Host: GitHub
- URL: https://github.com/outsystems/immutable-records
- Owner: OutSystems
- License: mit
- Created: 2016-02-03T19:18:30.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-02-23T21:30:17.000Z (almost 9 years ago)
- Last Synced: 2024-08-11T11:27:43.081Z (5 months ago)
- Topics: engineering, snyk-product
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 14
- Watchers: 11
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# immutable-records
[![npm version](https://badge.fury.io/js/immutable-records.svg)](https://badge.fury.io/js/immutable-records)
A simple implementation of immutable records for JavaScript.The goal of this implementation is to have great performance dealing with
records with a small, fixed set of attributes. [See here](https://medium.com/outsystems-engineering/javascript-and-immutability-how-fast-is-fast-enough-27790cda4e9e#.4xf0eiq4m) for a performance comparision with Facebook's [immutable-js](https://facebook.github.io/immutable-js/).This is the JavaScript version of the [TypeScript](https://github.com/OutSystems/immutable-records) version for use with npm.
### Install (via NPM)
```shell
$ npm install immutable-records
```### Usage
```javascript
var Record = require('immutable-records').Record;var ABRecord = Record({a:1, b:2});
var myRecord = new ABRecord({b:3});myRecord.get('b'); // 3
myRecord = myRecord.set('a', 4); // Returns a new Record
myRecord.get('a'); // 4myRecord.toJS(); // Returns a vanilla JS Object { a: 4, b: 3 }
```