New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

convertify

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convertify

A simple convesion tool from one object type to the next

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

convertify

A simple conversion tool from one object type to the next

Installation
$ npm i convertify --save
Usage
// ES2015
import to from "convertify";

// CommonJS
const to = require("convertify");

// script
const to = window.convertify;

Or you can bring in individual functions:

// in this case toString, which is the same as to.string

// ES2015
import { toString } from "convertify";

// CommonJS
const toString = require("convertify").toString;

// script
const toString = window.convertify.toString;
Implementation
const someObject = {
  foo: "bar"
};

// you can use the default method
const map = to("map", someObject); // Map {'foo' => 'bar'}

// or the convenience methods
const array = to.array(map); // ['bar']
API

Link here: API

to(convertTo: string, object: any)

The standard method accepts two parameters, the first being a string of the object class you wnat to convert the object to, and the second being the object itself. The valid object classes you can convert to:

  • array
  • boolean
  • date
  • error
  • function
  • generator
  • map
  • null
  • number
  • object
  • promise
  • regexp
  • set
  • string
  • symbol
  • undefined

These values are either the string value you pass in as the first parameter to to, or the shorthand method name for that specific conversion:

const stringifiedObject = to("string", object);

// is the same as

const alsoStringifiedObject = to.string(object);

The conversions themselves try to be smarter than the standard implicit conversions, so check out the API to learn more details about specific conversion results.

Development

Standard stuff, clone the repo and npm i to get the dependencies. npm scripts available:

  • build => builds the distributed JS with NODE_ENV=development and with sourcemaps
  • build-minified => builds the distributed JS with NODE_ENV=production and minified
  • compile-for-publish => runs the lint, test, transpile, build, and build-minified scripts
  • dev => runs the webpack dev server for the playground
  • lint => runs ESLint against files in the src folder
  • prepublish => if in publish, runs compile-for-publish
  • test => run ava with NODE_ENV=test
  • test:watch => runs test but with persistent watcher
  • transpile => runs Babel against files in src to files in lib

Keywords

FAQs

Package last updated on 07 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc