array-to-object-keys
Advanced tools
Comparing version 1.0.18 to 1.0.19
@@ -7,5 +7,5 @@ /** @module array-to-object-keys | ||
* @type {function} | ||
* @param {string} value The original array entry | ||
* @param {number} index The index of the array entry (starts at 0) | ||
* @returns {*} | ||
* @param {string} value Original array entry | ||
* @param {number} index Index of the array entry (starts at 0) | ||
* @returns {*} Anything that will be the object entry value | ||
*/ | ||
@@ -16,8 +16,11 @@ type valueGenerator = (value: string, index: number) => any; | ||
* @example | ||
* import arrayToObjectKeys from "array-to-object-keys" | ||
* arrayToObjectKeys(["a", "b"]) | ||
* // {a: null, b: null} | ||
* @example | ||
* import arrayToObjectKeys from "array-to-object-keys" | ||
* arrayToObjectKeys(["a", "b"], "value") | ||
* // {a: "value", b: "value"} | ||
* @example | ||
* import arrayToObjectKeys from "array-to-object-keys" | ||
* arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`) | ||
@@ -32,86 +35,3 @@ * // {a: "value for a #1", b: "value for b #2"} | ||
}; | ||
/** | ||
* @typedef valueGenerator | ||
* @type {function} | ||
* @param {string} value The original array entry | ||
* @param {number} index The index of the array entry (starts at 0) | ||
* @returns {*} | ||
*/ | ||
type valueGenerator = (value: string, index: number) => any; | ||
/** | ||
* Converts an array to an object with static keys and customizable values | ||
* @example | ||
* arrayToObjectKeys(["a", "b"]) | ||
* // {a: null, b: null} | ||
* @example | ||
* arrayToObjectKeys(["a", "b"], "value") | ||
* // {a: "value", b: "value"} | ||
* @example | ||
* arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`) | ||
* // {a: "value for a #1", b: "value for b #2"} | ||
* @param {string[]} array Keys for the generated object | ||
* @param {valueGenerator|*} [valueGenerator=null] Optional function that sets the object values based on key and index | ||
* @returns {Object<string, *>} A generated object based on the array input | ||
*/ | ||
function default(array: string[], valueGenerator?: valueGenerator | any): { | ||
[key: string]: any; | ||
}; | ||
} | ||
/** @module array-to-object-keys | ||
*/ | ||
declare module "array-to-object-keys" { | ||
/** | ||
* @typedef valueGenerator | ||
* @type {function} | ||
* @param {string} value The original array entry | ||
* @param {number} index The index of the array entry (starts at 0) | ||
* @returns {*} | ||
*/ | ||
type valueGenerator = (value: string, index: number) => any; | ||
/** | ||
* Converts an array to an object with static keys and customizable values | ||
* @example | ||
* arrayToObjectKeys(["a", "b"]) | ||
* // {a: null, b: null} | ||
* @example | ||
* arrayToObjectKeys(["a", "b"], "value") | ||
* // {a: "value", b: "value"} | ||
* @example | ||
* arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`) | ||
* // {a: "value for a #1", b: "value for b #2"} | ||
* @param {string[]} array Keys for the generated object | ||
* @param {valueGenerator|*} [valueGenerator=null] Optional function that sets the object values based on key and index | ||
* @returns {Object<string, *>} A generated object based on the array input | ||
*/ | ||
function default(array: string[], valueGenerator?: valueGenerator | any): { | ||
[key: string]: any; | ||
}; | ||
/** | ||
* @typedef valueGenerator | ||
* @type {function} | ||
* @param {string} value The original array entry | ||
* @param {number} index The index of the array entry (starts at 0) | ||
* @returns {*} | ||
*/ | ||
type valueGenerator = (value: string, index: number) => any; | ||
/** | ||
* Converts an array to an object with static keys and customizable values | ||
* @example | ||
* arrayToObjectKeys(["a", "b"]) | ||
* // {a: null, b: null} | ||
* @example | ||
* arrayToObjectKeys(["a", "b"], "value") | ||
* // {a: "value", b: "value"} | ||
* @example | ||
* arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`) | ||
* // {a: "value for a #1", b: "value for b #2"} | ||
* @param {string[]} array Keys for the generated object | ||
* @param {valueGenerator|*} [valueGenerator=null] Optional function that sets the object values based on key and index | ||
* @returns {Object<string, *>} A generated object based on the array input | ||
*/ | ||
function default(array: string[], valueGenerator?: valueGenerator | any): { | ||
[key: string]: any; | ||
}; | ||
} | ||
/*! | ||
*** array-to-object-keys 1.0.18 | ||
*** array-to-object-keys 1.0.19 | ||
*** Copyright © 2019, Jaid <jaid.jsx@gmail.com> (https://github.com/Jaid) | ||
*** Licensed under MIT | ||
*** @license MIT | ||
*** See https://array-to-object-keys.jaid.codes | ||
!*/ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t),t.default=((e,t=null)=>{if(!Array.isArray(e))return{};const r={};if("function"==typeof t){let n=0;for(const o of e)r[o]=t(o,n),n++}else for(const n of e)r[n]=t;return r})}])}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(global,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){"use strict";r.r(t),t.default=((e,t=null)=>{if(!Array.isArray(e))return{};const r={};if("function"==typeof t){let n=0;for(const o of e)r[o]=t(o,n),n++}else for(const n of e)r[n]=t;return r})}])}); | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
{"author":{"name":"Jaid","email":"jaid.jsx@gmail.com","url":"https://github.com/Jaid"},"bugs":"https://github.com/Jaid/array-to-object-keys/issues","description":"Converts an array to an object where the keys are the array entries and the values are customizable in a function.","homepage":"https://array-to-object-keys.jaid.codes","keywords":["array","array-manipulations","array-map","convert","javascript-array","javascript-object","keys","lang","object","values"],"license":"MIT","name":"array-to-object-keys","repository":"github:Jaid/array-to-object-keys","types":"index.d.ts","version":"1.0.18"} | ||
{"author":{"name":"Jaid","email":"jaid.jsx@gmail.com","url":"https://github.com/Jaid"},"bugs":"https://github.com/Jaid/array-to-object-keys/issues","description":"Converts an array to an object where the keys are the array entries and the values are customizable in a function.","homepage":"https://array-to-object-keys.jaid.codes","keywords":["array","array-manipulations","array-map","convert","javascript-array","javascript-object","keys","lang","object","values"],"license":"MIT","name":"array-to-object-keys","repository":"github:Jaid/array-to-object-keys","types":"index.d.ts","version":"1.0.19"} |
11940
6
45