magina
Version:
Node module magina (:construction: Under construction, usage is not recommended!)
36 lines • 1.23 kB
TypeScript
/** @module magina
*/
declare module "magina" {
/**
* Returns `value`, or `[value]` if `value` is not an array
* @param {*} value The value that will be converted to an array
* @example
* import {ensureArray} from "magina"
* ensureArray("abc")
* // ["abc"]
* @returns {*[]} An array
*/
var ensureArray: any;
/**
* 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 "magina"
* ensureObject("abc", "importantKey")
* // { importantKey: "abc" }
* @returns {object} An object
*/
var ensureObject: any;
/**
* Returns `value`, or `value[key]` if `value` is not an object
* @param {*} value The value that might be an object
* @param {string} key The key whose value gets used on possible unpacking
* @example
* import {unpackObject} from "magina"
* unpackObject({id: "abc"}, "id")
* // "abc"
* @returns {object} Either the value or an unpacked value
*/
var unpackObject: any;
}