@ibnlanre/objectify
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

objectify

A utility for converting a JS reference type to an object

Install

npm i @ibnlanre/objectify

Import

// Browser
<script src="https://unpkg.com/@ibnlanre/objectify"></script>;

// ES6 Import
import objectify from "@ibnlanre/objectify"

// NodeJS Require
const objectify = require("@ibnlanre/objectify");

API

objectify(item [, callbackFn [, thisArg]])

Usage

objectify(5) // {}

// callbacks should return an array
const cb = ([value, key], index, item) => [index, value]

// { 0: 6, 1: 8, 2: 90 }
objectify(new Set([6, 8, 90]), cb)

// {  0: "zero", 1: [4, 5, 6] }
objectify(new Map([[0, "zero"], [1, [4, 5, 6]]]))

// { 0: "h", 1: "e", 2: "l", 3: "p" }
objectify("help")

Package Sidebar

Install

npm i @ibnlanre/objectify

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

3.95 kB

Total Files

5

Last publish

Collaborators

  • ibnlanre