resolve-normalize.js 616 B

1234567891011121314151617
  1. "use strict";
  2. var callable = require("es5-ext/object/valid-callable");
  3. module.exports = function (userNormalizer) {
  4. var normalizer;
  5. if (typeof userNormalizer === "function") return { set: userNormalizer, get: userNormalizer };
  6. normalizer = { get: callable(userNormalizer.get) };
  7. if (userNormalizer.set !== undefined) {
  8. normalizer.set = callable(userNormalizer.set);
  9. if (userNormalizer.delete) normalizer.delete = callable(userNormalizer.delete);
  10. if (userNormalizer.clear) normalizer.clear = callable(userNormalizer.clear);
  11. return normalizer;
  12. }
  13. normalizer.set = normalizer.get;
  14. return normalizer;
  15. };