* chore: 🤖 upgrade ember-data to v5.3.11 * Add missing copyright headers * refactor: 💡 remove comment * chore: 🤖 update yarn.lock due to merge conflict ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * fix: 🐛 undo ember-source upgrade (should be upgraded w/ ember) ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * chore: 🤖 move dep to devDeps & resolve test-helper version ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * fix: 🐛 unique record id error bug fix using store.push ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * refactor: 💡 cleanup ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * Delete old deprecation initializer (#2748) * refactor: 💡 import from'ember-data/store' ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * refactor: 💡 clean up comments ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 * refactor: 💡 remove compatWith comment ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-16544 --------- Co-authored-by: Carlos Alcaide Corvo <ccorvo@hashicorp.com>
31 lines
592 B
JavaScript
31 lines
592 B
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
export default class ObjectAsArrayTransform {
|
|
deserialize(serialized) {
|
|
const obj = serialized || {};
|
|
return Object.entries(obj).map(([key, value]) => ({ key, value }));
|
|
}
|
|
|
|
serialize(deserialized) {
|
|
const array = deserialized || [];
|
|
|
|
if (!array.length) {
|
|
return null;
|
|
}
|
|
|
|
return array.reduce((result, currentValue) => {
|
|
const { key, value } = currentValue;
|
|
result[key] = value;
|
|
|
|
return result;
|
|
}, {});
|
|
}
|
|
|
|
static create() {
|
|
return new this();
|
|
}
|
|
}
|