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

@shopify/decorators

Package Overview
Dependencies
Maintainers
13
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/decorators - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

6

CHANGELOG.md

@@ -10,2 +10,8 @@ # Changelog

## 1.1.0 - 2019-03-22
### Changed
- move to use the enhancer version of `memoize` ([#594](https://github.com/Shopify/quilt/pull/594))
## 1.0.1 - 2019-03-11

@@ -12,0 +18,0 @@

4

dist/memoize.d.ts

@@ -1,4 +0,2 @@

declare type Resolver<T extends Function> = T;
export declare const MAX_MAP_ENTRIES = 50;
export declare type Resolver<T extends Function> = T;
export default function memoize<Method extends Function>(resolver?: Resolver<Method>): MethodDecorator;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
exports.MAX_MAP_ENTRIES = 50;
var function_enhancers_1 = require("@shopify/function-enhancers");
function memoize(resolver) {

@@ -15,3 +14,3 @@ return function (_target, propertyKey, descriptor) {

configurable: true,
value: memoized(method, resolver),
value: function_enhancers_1.memoize(method, resolver),
};

@@ -25,44 +24,1 @@ Object.defineProperty(this, propertyKey, newDescriptor);

exports.default = memoize;
function memoized(method, resolver) {
var weakMapCache = new WeakMap();
var mapCache = new Map();
var mapKeys = [];
return function memoized() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (typeof window === 'undefined') {
return method.apply(this, args);
}
var useWeakMap = args.length === 1 && typeof args[0] === 'object' && !resolver;
var key;
if (useWeakMap) {
key = args[0];
}
else if (resolver && resolver instanceof Function) {
key = resolver.apply(void 0, tslib_1.__spread(args));
}
else {
key = args[0];
}
var cache = useWeakMap ? weakMapCache : mapCache;
if (cache.has(key)) {
return cache.get(key);
}
var result = method.apply(this, args);
if (useWeakMap) {
weakMapCache.set(key, result);
}
else {
mapCache.set(key, result);
mapKeys.push(key);
if (mapCache.size > exports.MAX_MAP_ENTRIES) {
var oldestKey = mapKeys[0];
mapCache.delete(oldestKey);
mapKeys.shift();
}
}
return result;
};
}
{
"name": "@shopify/decorators",
"version": "1.0.2",
"version": "1.1.0",
"license": "MIT",

@@ -31,3 +31,6 @@ "description": "A set of decorators to aid your JavaScript journey.",

"dist/*"
]
],
"dependencies": {
"@shopify/function-enhancers": "^1.0.0"
}
}
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