Socket
Socket
Sign inDemoInstall

immutablejs-record-memoize

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    immutablejs-record-memoize

Memoize methods and properties of ImmutableJS.Record


Version published
Weekly downloads
316
decreased by-4.53%
Maintainers
1
Install size
148 kB
Created
Weekly downloads
 

Changelog

Source

1.0.1

  • Improved memory performance by using WeakMap and a global cache (no longer adding __cache to object instances). Tested for Immutable 4 as well.

Readme

Source

immutablejs-record-memoize

npm

Memoize methods or properties of any ImmutableJS.Record. Also works on any immutable object prototype.

Install

yarn add immutablejs-record-memoize

Usage

With ImmutableJS.Record:

import memoize from 'immutablejs-record-memoize';

class ExampleRecord extends Record({}) {
    noArguments() {
        // ...
    },

    withArguments(a, b, c) {
        // ...
    }
}

memoize(ExampleRecord.prototype, ['noArguments', 'withArguments']);

// Use ExampleRecord as usual

For other object's prototypes:

import memoize from 'immutablejs-record-memoize';

function ExampleObject() {
    constructor() {
        // ...
    }
}

ExampleObject.prototype = {
    noArguments() {
        // ...
    },

    withArguments(a, b, c) {
        // ...
    }
};

// Memoize methods with no arguments
memoize(ExampleObject.prototype, ['noArguments', 'withArguments']);

// Use ExampleObject as usual

Reference

memoize

Memoize the given properties of the given prototype object. The prototype is mutated.

Arguments:

  • prototype: Object The object prototype that should have its properties memoized.
  • properties: string[] The list of properties names that should be memoized

Returns: void

Credits

Implementation is taken from Slate. https://github.com/ianstormtaylor/slate/blob/master/src/utils/memoize.js

Thank you to:

Keywords

FAQs

Last updated on 06 Jan 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc