@lyra/form-builder
Version:
Lyra form builder
53 lines (44 loc) • 1.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.setIfMissing = setIfMissing;
exports.insert = insert;
exports.set = set;
exports.unset = unset;
exports.inc = inc;
exports.dec = dec;
exports.prefixPath = prefixPath;
function setIfMissing(value /*: any*/, path /*: Path*/ = []) /*: SetIfMissingPatch*/ {
return {
type: 'setIfMissing',
path,
value
};
}
function insert(items /*: any[]*/, position /*: InsertPosition*/, path /*: Path*/ = []) /*: InsertPatch*/ {
return {
type: 'insert',
path,
position,
items
};
}
function set(value /*: any*/, path /*: Path*/ = []) /*: SetPatch*/ {
return { type: 'set', path, value };
}
function unset(path /*: Path*/ = []) /*: UnsetPatch*/ {
return { type: 'unset', path };
}
function inc(amount = 1, path /*: Path*/ = []) /*: IncPatch*/ {
return { type: 'inc', path, value: amount };
}
function dec(amount = 1, path /*: Path*/ = []) /*: DecPatch*/ {
return { type: 'dec', path, value: amount };
}
function prefixPath /*:: <T: HasPath>*/(patch /*: T*/, segment /*: PathSegment*/) /*: T*/ {
return _extends({}, patch, {
path: [segment, ...patch.path]
});
}