buffer-methods
Advanced tools
Comparing version 1.0.1 to 1.0.2
16
index.js
@@ -5,2 +5,3 @@ const _ = require('lodash'); | ||
let _methodBuffer = []; | ||
let _resolved = false; | ||
const _model = _.reduce( | ||
@@ -11,3 +12,7 @@ _.keys(model), | ||
acc[key] = (...args) => { | ||
_methodBuffer.push({ key, args }); | ||
if (!_resolved) { | ||
_methodBuffer.push({ key, args }); | ||
} else { | ||
model[key](...args); | ||
} | ||
}; | ||
@@ -23,8 +28,9 @@ } else { | ||
model: _model, | ||
resolve: function () { | ||
_.extendWith(_model, model); | ||
_.forEach(_methodBuffer, ({ key, args }) => model[key].apply({}, args)); | ||
resolve: function (newModel) { | ||
_.extendWith(_model, model, newModel); | ||
_resolved = true; | ||
_.forEach(_methodBuffer, ({ key, args }) => model[key](...args)); | ||
_methodBuffer = []; | ||
} | ||
} | ||
}; | ||
}; |
{ | ||
"name": "buffer-methods", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Allows you to delay object method resolution until a resolve function is called", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
1363
44
1