You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
"use strict"; |
|
var __assign = (this && this.__assign) || function () { |
|
__assign = Object.assign || function(t) { |
|
for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
s = arguments[i]; |
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) |
|
t[p] = s[p]; |
|
} |
|
return t; |
|
}; |
|
return __assign.apply(this, arguments); |
|
}; |
|
Object.defineProperty(exports, "__esModule", { value: true }); |
|
exports.DataBuddy = void 0; |
|
var DataBuddy = (function () { |
|
function DataBuddy(records) { |
|
var _this = this; |
|
this.get = function () { |
|
return _this.data; |
|
}; |
|
this.getOne = function (id) { |
|
return _this.data.find(function (record) { return record.id === id; }) || null; |
|
}; |
|
this.update = function (id, params) { |
|
var index = _this.data.findIndex(function (record) { return record.id === id; }); |
|
if (!index) |
|
return false; |
|
var record = _this.data[index]; |
|
_this.data[index] = __assign(__assign({}, record), params); |
|
return _this.data[index]; |
|
}; |
|
this.delete = function (id) { |
|
var index = _this.data.findIndex(function (record) { return record.id === id; }); |
|
if (!index) |
|
return false; |
|
_this.data.splice(index, 1); |
|
return true; |
|
}; |
|
this.data = records; |
|
} |
|
return DataBuddy; |
|
}()); |
|
exports.DataBuddy = DataBuddy;
|
|
|