Define once

This commit is contained in:
Mariusz Nowak
2013-07-22 20:24:04 +02:00
parent 9fd0ef8d24
commit baae9f8d54

View File

@@ -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;