@openactive/data-model-validator
Version:
A library to allow a developer to validate a JSON document against the OpenActive Modelling Opportunity Specification
28 lines (26 loc) • 490 B
JavaScript
/**
* A shorthand to create an object where keys and values are the same.
*
* e.g.
*
* ```js
* > SelfIndexingObject.create(['a', 'b', 'c'])
* { a: 'a', b: 'b', c: 'c' }
* ```
*/
const SelfIndexingObject = {
/**
* @template TKey
* @param {TKey[]} keys
* @returns {Record<TKey, TKey>}
*/
create(keys) {
return keys.reduce((acc, key) => {
acc[key] = key;
return acc;
}, /** @type {any} */({}));
},
};
module.exports = {
SelfIndexingObject,
};