This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@blinkmobile/cast-property-types

1.0.0 • Public • Published

cast-property-types.js

coerce properties within an Object to other types

npm module

travis-ci

What is this?

This is a utility function to take an Object that has properties with String values, and cast those Strings to other type (e.g. Booleans and Numbers).

API

castPropertyTypes()

  • @param {Object} input key-value pairs to cast
  • @param {Object} example key-value pairs where values are of desired types
  • @returns {Object} a new Object with same properties as input but with cast values

castPropertyTypes() will take the values from the first parameter, and cast those values using the types found in the second parameter.

For example, castPropertyTypes({ value: '123' }, { value: 0 }) will return:

{
  "value": 123
}

We use the built-in parseFloat() method to cast values to a Number, so be aware that values that are not numeric may have unexpected results.

Readme

Keywords

Package Sidebar

Install

npm i @blinkmobile/cast-property-types

Weekly Downloads

0

Version

1.0.0

License

BSD-3-Clause

Last publish

Collaborators

  • aaronroworth
  • blinkmobile-admin
  • kizaonline
  • mymattcarroll
  • simon_marklar