From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- addon-sdk/source/lib/diffpatcher/patch.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 addon-sdk/source/lib/diffpatcher/patch.js (limited to 'addon-sdk/source/lib/diffpatcher/patch.js') diff --git a/addon-sdk/source/lib/diffpatcher/patch.js b/addon-sdk/source/lib/diffpatcher/patch.js new file mode 100644 index 000000000..9271e8893 --- /dev/null +++ b/addon-sdk/source/lib/diffpatcher/patch.js @@ -0,0 +1,21 @@ +"use strict"; + +var method = require("../method/core") +var rebase = require("./rebase") + +// Method is designed to work with data structures representing application +// state. Calling it with a state and delta should return object representing +// new state, with changes in `delta` being applied to previous. +// +// ## Example +// +// patch(state, { +// "item-id-1": { completed: false }, // update +// "item-id-2": null // delete +// }) +var patch = method("patch@diffpatcher") +patch.define(Object, function patch(hash, delta) { + return rebase({}, hash, delta) +}) + +module.exports = patch -- cgit v1.2.3