Get unlimited public & private packages + team-based management with npm Teams.Learn more »

tiny-coerce

1.1.1 • Public • Published

Tiny Coerce

build status

String to primitive coercion for Client or Server. It's great for DOM data attributes, localStorage, and other cases where your need to store a String.

API

coerce (arg[, deep = false])

Returns a coercion of arg. Deep coercion is optional with the second parameter.

First parameter is trimmed before coercion!

Example

const coerce = require("tiny-coerce");
 
console.log(coerce("true")); // true
console.log(coerce("null")); // null
console.log(coerce({a: {b: "50"}}, true).a.b) // 50

License

Copyright (c) 2018 Jason Mulligan Licensed under the BSD-3 license

Install

npm i tiny-coerce

DownloadsWeekly Downloads

21

Version

1.1.1

License

BSD-3-Clause

Unpacked Size

5.13 kB

Total Files

4

Last publish

Collaborators

  • avatar