ensure-object
Version:
If given value is not an object, returns an object with one entry.
17 lines • 590 B
TypeScript
/** @module ensure-object
*/
declare module "ensure-object" {
/**
* Returns `value`, or `{key: value}` if `value` is not an object
* @param {*} value The value that will be converted to an array
* @param {string} key The key of the object entry that might be created on a new object
* @example
* import ensureObject from "ensure-object"
* ensureObject("abc", "importantKey")
* // { importantKey: "abc" }
* @returns {Object<string, *>} An object
*/
export default function(value: any, key: string): {
[key: string]: any;
};
}