mirror of
https://github.com/BreizhHardware/memoizee.git
synced 2026-03-18 21:40:27 +01:00
Define once
This commit is contained in:
@@ -8,7 +8,19 @@ var CustomError = require('es5-ext/lib/Error/custom')
|
||||
, serialize0 = function () { return ''; }
|
||||
, serialize1 = function (args) { return args[0]; }
|
||||
|
||||
, apply = Function.prototype.apply, call = Function.prototype.call;
|
||||
, apply = Function.prototype.apply, call = Function.prototype.call
|
||||
, serializeN;
|
||||
|
||||
serializeN = function (args) {
|
||||
var id = '', i, length = args.length;
|
||||
if (length) {
|
||||
id += args[i = 0];
|
||||
while (--length) id += '\u0001' + args[++i];
|
||||
} else {
|
||||
id = '\u0002';
|
||||
}
|
||||
return id;
|
||||
};
|
||||
|
||||
module.exports = require('./_base')(function (conf, length) {
|
||||
var get, cache = conf.cache = {}, fn
|
||||
@@ -17,16 +29,7 @@ module.exports = require('./_base')(function (conf, length) {
|
||||
if (length === 1) {
|
||||
get = conf.get = serialize1;
|
||||
} else if (length === false) {
|
||||
get = conf.get = function (args) {
|
||||
var id = '', i, length = args.length;
|
||||
if (length) {
|
||||
id += args[i = 0];
|
||||
while (--length) id += '\u0001' + args[++i];
|
||||
} else {
|
||||
id = '\u0002';
|
||||
}
|
||||
return id;
|
||||
};
|
||||
get = conf.get = serializeN;
|
||||
} else if (length) {
|
||||
get = conf.get = function (args) {
|
||||
var id = String(args[0]), i = 0, l = length;
|
||||
|
||||
Reference in New Issue
Block a user