Remove support for serialize option

Instead support function value for `normalizer`
This commit is contained in:
Mariusz Nowak
2014-04-27 12:17:37 +02:00
parent eb72d16bf6
commit 50cb4cfde1
3 changed files with 13 additions and 13 deletions

View File

@@ -7,7 +7,7 @@ var normalizeOpts = require('es5-ext/object/normalize-options')
module.exports = function (fn/*, options*/) {
var options = normalizeOpts(arguments[1]), length;
if (!options.normalizer && !options.serialize) {
if (!options.normalizer) {
length = options.length = resolveLength(options.length, fn.length, options.async);
if (length === 0) {
options.normalizer = require('./lib/normalizers/0');

View File

@@ -27,18 +27,18 @@ module.exports = function (original, length, options) {
else memLength = original.length;
if (options.normalizer) {
get = callable(options.normalizer.get);
if (options.normalizer.set !== undefined) {
set = callable(options.normalizer.set);
del = callable(options.normalizer.delete);
clear = callable(options.normalizer.clear);
if (typeof options.normalizer === 'function') {
set = get = options.normalizer;
} else {
set = get;
get = callable(options.normalizer.get);
if (options.normalizer.set !== undefined) {
set = callable(options.normalizer.set);
del = callable(options.normalizer.delete);
clear = callable(options.normalizer.clear);
} else {
set = get;
}
}
} else if (options.serialize) {
set = get = (function (serialize) {
return function (args) { return serialize.apply(null, args); };
}(callable(options.serialize)));
}
if (options.resolvers != null) {

View File

@@ -90,9 +90,9 @@ module.exports = function (t, a) {
}
};
},
"Serialize": function () {
"Normalizer function": function () {
var i = 0, fn = function () { ++i; return join.call(arguments, '|'); }, mfn;
mfn = t(fn, { serialize: Boolean });
mfn = t(fn, { normalizer: function (args) { return Boolean(args[0]); } });
a(mfn(false, 'raz'), 'false|raz', "#1");
a(mfn(0, 'dwa'), 'false|raz', "#2");
a(i, 1, "Called once");