@berish/serber
Advanced tools
Comparing version 1.1.6 to 1.1.7
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -14,36 +23,44 @@ const const_1 = require("../const"); | ||
params[const_1.SERBER_KEY_SYMBOL] = params[const_1.SERBER_KEY_SYMBOL] || ''; | ||
return obj.map((m, i) => { | ||
params[const_1.SERBER_PARENT_OBJECT_SYMBOL] = obj; | ||
params[const_1.SERBER_KEY_SYMBOL] = i; | ||
return params[const_1.SERBER_INSTANCE_SYMBOL].serialize(m, Object.assign(Object.assign({}, params), { [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(i) })); | ||
}); | ||
const serialized = []; | ||
const indexes = obj.keys(); | ||
for (const index of indexes) { | ||
const newParams = Object.assign(Object.assign({}, params), { [const_1.SERBER_PARENT_OBJECT_SYMBOL]: obj, [const_1.SERBER_KEY_SYMBOL]: index, [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(index) }); | ||
serialized[index] = params[const_1.SERBER_INSTANCE_SYMBOL].serialize(obj[index], newParams); | ||
} | ||
return serialized; | ||
}, | ||
serializeAsync: (obj, params) => { | ||
serializeAsync: (obj, params) => __awaiter(void 0, void 0, void 0, function* () { | ||
params[const_1.SERBER_PATH_SYMBOL] = params[const_1.SERBER_PATH_SYMBOL] || []; | ||
params[const_1.SERBER_KEY_SYMBOL] = params[const_1.SERBER_KEY_SYMBOL] || ''; | ||
return Promise.all(obj.map((m, i) => { | ||
params[const_1.SERBER_PARENT_OBJECT_SYMBOL] = obj; | ||
params[const_1.SERBER_KEY_SYMBOL] = i; | ||
return params[const_1.SERBER_INSTANCE_SYMBOL].serializeAsync(m, Object.assign(Object.assign({}, params), { [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(i) })); | ||
})); | ||
}, | ||
const serialized = []; | ||
const indexes = obj.keys(); | ||
for (const index of indexes) { | ||
const newParams = Object.assign(Object.assign({}, params), { [const_1.SERBER_PARENT_OBJECT_SYMBOL]: obj, [const_1.SERBER_KEY_SYMBOL]: index, [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(index) }); | ||
serialized[index] = yield params[const_1.SERBER_INSTANCE_SYMBOL].serializeAsync(obj[index], newParams); | ||
} | ||
return serialized; | ||
}), | ||
deserialize: (obj, params) => { | ||
params[const_1.SERBER_PATH_SYMBOL] = params[const_1.SERBER_PATH_SYMBOL] || []; | ||
params[const_1.SERBER_KEY_SYMBOL] = params[const_1.SERBER_KEY_SYMBOL] || ''; | ||
return obj.map((m, i) => { | ||
params[const_1.SERBER_PARENT_OBJECT_SYMBOL] = obj; | ||
params[const_1.SERBER_KEY_SYMBOL] = i; | ||
return params[const_1.SERBER_INSTANCE_SYMBOL].deserialize(m, Object.assign(Object.assign({}, params), { [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(i) })); | ||
}); | ||
const deserialized = []; | ||
const indexes = obj.keys(); | ||
for (const index of indexes) { | ||
const newParams = Object.assign(Object.assign({}, params), { [const_1.SERBER_PARENT_OBJECT_SYMBOL]: obj, [const_1.SERBER_KEY_SYMBOL]: index, [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(index) }); | ||
deserialized[index] = params[const_1.SERBER_INSTANCE_SYMBOL].deserialize(obj[index], newParams); | ||
} | ||
return deserialized; | ||
}, | ||
deserializeAsync: (obj, params) => { | ||
deserializeAsync: (obj, params) => __awaiter(void 0, void 0, void 0, function* () { | ||
params[const_1.SERBER_PATH_SYMBOL] = params[const_1.SERBER_PATH_SYMBOL] || []; | ||
params[const_1.SERBER_KEY_SYMBOL] = params[const_1.SERBER_KEY_SYMBOL] || ''; | ||
return Promise.all(obj.map((m, i) => { | ||
params[const_1.SERBER_PARENT_OBJECT_SYMBOL] = obj; | ||
params[const_1.SERBER_KEY_SYMBOL] = i; | ||
return params[const_1.SERBER_INSTANCE_SYMBOL].deserializeAsync(m, Object.assign(Object.assign({}, params), { [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(i) })); | ||
})); | ||
}, | ||
const deserialized = []; | ||
const indexes = obj.keys(); | ||
for (const index of indexes) { | ||
const newParams = Object.assign(Object.assign({}, params), { [const_1.SERBER_PARENT_OBJECT_SYMBOL]: obj, [const_1.SERBER_KEY_SYMBOL]: index, [const_1.SERBER_PATH_SYMBOL]: params[const_1.SERBER_PATH_SYMBOL].concat(index) }); | ||
deserialized[index] = yield params[const_1.SERBER_INSTANCE_SYMBOL].deserializeAsync(obj[index], newParams); | ||
} | ||
return deserialized; | ||
}), | ||
}; | ||
//# sourceMappingURL=array.js.map |
{ | ||
"name": "@berish/serber", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "Serializable and deserializable adaptive adapter with plugins", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58966
698