Auto Parse
What is Auto Parse
auto-parse
any value you happen to send in (String
, Number
, Boolean
,
Array
, Object
, Function
, undefined
and null
). You send it we will
try to find a way to parse it. We now support sending in a string of what type (e.g. "boolean") or constructor (e.g. Boolean)
Installation
# NPMnpm install auto-parse --save# YARNyarn add auto-parse
Whats New
- #11 Removed Lodash
- #12 Browser Support
- #14 parse object (amazon support)
- #16 Support For Object.create(null)
- #17 Support Instances of Date & Regex Constructors
- #18 Parsing Array Strings Only Works On Double Quotes
Documentation
autoParse(input, type)
Params
- Anything
input
: The input value you want parsed - Constructor|String
type
: The type. It could be a string (e.g. "array") or a constructor (e.g. Array).
Return
- Parsed Value Could return String, Number, Boolean, Object, Array, Null, NaN, Undefined & Date
Usage
var autoParse = // Strings 'Green Pioneer'// Booleans true false// Functions 9// Null & Undefined undefined null// Objects & Arrays 23322343234323423233 80 92 23 true false 80 92 23 true false 80 92 23 true false 80 92 23 true false 80 92 23 true false name:'jason'age:50admin:truegrade:8090100 {} 42 test: Object Object Object Object// Numbers NaN 26// hexadecimals 255// dots 042// octals 83// binary number 13// exponent 7000 // Set Type true 0 true 0 '1234'// dates Thu Nov 30 1989 18:00:00 GMT- Thu Nov 30 1989 18:00:00 GMT-// Passing Functions to type { thiscolor = inputColor} color: '#AAA'// Specific Instances Thu Nov 30 1989 18:00:00 GMT- /123/ // Regex// functions that return no props - Object.create(null) order:'asc' orderBy:1
Other Uses
Lodash
// Lodash Mixinvar autoParse =_
Browser Support
Auto Parse
License
The MIT License (MIT)
Copyright (c) 2014-2019 Green Pioneer
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Created by