@naturalcycles/js-lib
Advanced tools
Comparing version 4.5.0 to 4.5.1
@@ -0,1 +1,8 @@ | ||
## [4.5.1](https://github.com/NaturalCycles/js-lib/compare/v4.5.0...v4.5.1) (2019-04-08) | ||
### Bug Fixes | ||
* **memo:** disable 0-arg optimization ([56ff7d4](https://github.com/NaturalCycles/js-lib/commit/56ff7d4)) | ||
# [4.5.0](https://github.com/NaturalCycles/js-lib/compare/v4.4.1...v4.5.0) (2019-03-30) | ||
@@ -2,0 +9,0 @@ |
@@ -13,3 +13,3 @@ // Based on: | ||
/* tslint:disable:no-invalid-this */ | ||
import { jsonMemoSerializer, MapMemoCache, SingleValueMemoCache } from './memo.util'; | ||
import { jsonMemoSerializer, MapMemoCache } from './memo.util'; | ||
/** | ||
@@ -28,13 +28,17 @@ * Memoizes the method of the class, so it caches the output and returns the cached version if the "key" | ||
const originalFn = descriptor.value; | ||
// console.log('len: ' + originalFn.length) | ||
let cache; | ||
// console.log(`${key} len: ${originalFn.length}`) | ||
// todo: optimization disabled until "default arg value" use case is solved (see memo.decorator.test.ts) | ||
/* | ||
let cache: MemoCache | ||
// Function with 0 arguments | ||
if (!originalFn.length) { | ||
cache = new SingleValueMemoCache(); | ||
cache = new SingleValueMemoCache() | ||
} else { | ||
// Function with > 0 arguments | ||
cache = new MapMemoCache() | ||
// cache = new ObjectMemoCache() | ||
} | ||
else { | ||
// Function with > 0 arguments | ||
cache = new MapMemoCache(); | ||
// cache = new ObjectMemoCache() | ||
} | ||
*/ | ||
const cache = new MapMemoCache(); | ||
descriptor.value = function (...args) { | ||
@@ -41,0 +45,0 @@ const cacheKey = jsonMemoSerializer(args); |
@@ -29,13 +29,17 @@ "use strict"; | ||
const originalFn = descriptor.value; | ||
// console.log('len: ' + originalFn.length) | ||
let cache; | ||
// console.log(`${key} len: ${originalFn.length}`) | ||
// todo: optimization disabled until "default arg value" use case is solved (see memo.decorator.test.ts) | ||
/* | ||
let cache: MemoCache | ||
// Function with 0 arguments | ||
if (!originalFn.length) { | ||
cache = new memo_util_1.SingleValueMemoCache(); | ||
cache = new SingleValueMemoCache() | ||
} else { | ||
// Function with > 0 arguments | ||
cache = new MapMemoCache() | ||
// cache = new ObjectMemoCache() | ||
} | ||
else { | ||
// Function with > 0 arguments | ||
cache = new memo_util_1.MapMemoCache(); | ||
// cache = new ObjectMemoCache() | ||
} | ||
*/ | ||
const cache = new memo_util_1.MapMemoCache(); | ||
descriptor.value = function (...args) { | ||
@@ -42,0 +46,0 @@ const cacheKey = memo_util_1.jsonMemoSerializer(args); |
{ | ||
"name": "@naturalcycles/js-lib", | ||
"version": "4.5.0", | ||
"version": "4.5.1", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "build": "del ./dist && tsc", |
@@ -16,3 +16,3 @@ // Based on: | ||
import { jsonMemoSerializer, MapMemoCache, MemoCache, SingleValueMemoCache } from './memo.util' | ||
import { jsonMemoSerializer, MapMemoCache, MemoCache } from './memo.util' | ||
@@ -37,4 +37,6 @@ /** | ||
const originalFn = descriptor.value | ||
// console.log('len: ' + originalFn.length) | ||
// console.log(`${key} len: ${originalFn.length}`) | ||
// todo: optimization disabled until "default arg value" use case is solved (see memo.decorator.test.ts) | ||
/* | ||
let cache: MemoCache | ||
@@ -50,2 +52,4 @@ | ||
} | ||
*/ | ||
const cache: MemoCache = new MapMemoCache() | ||
@@ -52,0 +56,0 @@ descriptor.value = function (...args: any[]): any { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123561
2327