Change createObject to use the new requireProperties API, and automatically validate the existence of the properties listed in the 'requiredProperties' for an object

master
Sven Slootweg 7 years ago
parent ed59e36ea0
commit 7e08b13854

@ -3,14 +3,11 @@
const createEventEmitter = require("create-event-emitter");
const defaultValue = require("default-value");
const validateSync = require("./validate-sync");
const requireProperties = require("./require-properties");
const calculateOriginOffsets = require("./calculate-origin-offsets");
module.exports = function createObject(options) {
validateSync(options, {
type: "required",
onRecalculateSize: "required"
});
requireProperties(options, ["type", "onRecalculateSize"].concat(defaultValue(options.requiredProperties, [])));
let object = createEventEmitter(Object.assign({
isCached: false,

Loading…
Cancel
Save