mirror of
https://github.com/BreizhHardware/memoizee.git
synced 2026-03-18 21:40:27 +01:00
serialize option, for custom args serialization
This commit is contained in:
@@ -33,7 +33,7 @@ module.exports = exports = function (core) {
|
||||
length = (options.length === false) ? false : (options.length >>> 0);
|
||||
}
|
||||
|
||||
core(conf, length);
|
||||
core(conf, length, options);
|
||||
|
||||
forEach(ext, function (fn, name) {
|
||||
if (fn.force) fn(conf, options);
|
||||
|
||||
@@ -18,5 +18,6 @@ require('./ext/max');
|
||||
|
||||
module.exports = function (fn/* options */) {
|
||||
var options = Object(arguments[1]);
|
||||
return call.call(options.primitive ? primitive : regular, this, fn, options);
|
||||
return call.call((options.primitive || options.serialize) ?
|
||||
primitive : regular, this, fn, options);
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
'use strict';
|
||||
|
||||
var CustomError = require('es5-ext/lib/Error/custom')
|
||||
, callable = require('es5-ext/lib/Object/valid-callable')
|
||||
, hasListeners = require('event-emitter/lib/has-listeners')
|
||||
|
||||
, serialize0 = function () { return ''; }
|
||||
@@ -22,11 +23,14 @@ serializeN = function (args) {
|
||||
return id;
|
||||
};
|
||||
|
||||
module.exports = require('./_base')(function (conf, length) {
|
||||
module.exports = require('./_base')(function (conf, length, options) {
|
||||
var get, cache = conf.cache = {}, fn
|
||||
, hitListeners, initListeners, purgeListeners;
|
||||
, hitListeners, initListeners, purgeListeners, serialize;
|
||||
|
||||
if (length === 1) {
|
||||
if (options.serialize) {
|
||||
serialize = callable(options.serialize);
|
||||
get = conf.get = function (args) { return serialize.apply(this, args); };
|
||||
} else if (length === 1) {
|
||||
get = conf.get = serialize1;
|
||||
} else if (length === false) {
|
||||
get = conf.get = serializeN;
|
||||
|
||||
Reference in New Issue
Block a user