New:Microsoft Teams Notifications Are Now Available in Socket.Learn more →
Get Started

cli-native

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-native

Native type conversion functions

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
95
69.64%
Maintainers
1
Weekly downloads
 
Created
Source

Native

Utility functions for converting strings to native types and vice versa.

Install

npm install cli-native

Test

npm test

API

var native = require('cli-native');
native.to('1,2,3', ',');                    // => [1, 2, 3]
native.to('true');                          // => true
native.to('false');                         // => false
native.to('null');                          // => null
native.to('undefined');                     // => undefined
native.to('value');                         // => 'value'
native.to('{"arr":[1,2,3]}', null, true);   // => {arr: [1, 2 ,3]}

to(str, [delimiter], [json])

Convert a string to a native type.

  • str: The string to convert.
  • delimiter: A delimiter to use to convert to arrays.
  • json: A boolean indicating that strings that appear to be JSON should be parsed.

from(val, [delimiter], [json])

Convert a native type to a string.

  • val: The value to convert to a string.
  • delimiter: A delimiter to used to join arrays.
  • json: A boolean indicating that complex objects should be serialized to JSON.

License

Everything is MIT. Read the license if you feel inclined.

Keywords

cli

FAQs

Package last updated on 04 Feb 2014

Related posts