![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
A utility to convert number-like strings in objects/arrays into numbers.
Numbrify is a small utility to convert number-like strings in objects and arrays into actual numbers. For example If you've ever parsed a csv file and gotten a bunch of numbers-as-strings in your object, this can help with converting those back to numbers. It will leave things that don't look like numbers alone.
NOTE: By default, Numbrify will do a deep traversal of properties/elements in the collection, however non primitive values that are not Arrays or Objects (e.g. dates) are copied by reference. So if you want a completely separate result and have lots of non primitive values you should deep clone your object first.
You can download a copy of the whole thing from the releases page. Or if you just want the built script there is here. Or if you are using npm, npm install numbrify
.
Include the script into your page. Possibly like so <script src="dist/numbrify.js" charset="utf-8"></script>
. The src
attribute should point to wherever you downloaded the dist/numbrify.js file to.
Then call Numbrify(data, deepTraversal=true)
with your collection. Here are some quick examples
var data;
var result;
// Numbrify an array
data = ["123", "456", "789.2342", "foo"];
result = Numbrify(data);
// Result should equal: [123, 456, 789.2342, "foo"];
data = [
{"name": "foo", "age": "42"},
{"name": "bar", "age": "32"},
{"name": "baz", "age": "22"}
]
// Numbrify an array of objects
result = Numbrify(data)
// Result should equal:
// [
// {"name": "foo", "age": 42},
// {"name": "foo", "age": 32},
// {"name": "foo", "age": 22}
// ]
// You can also do
result = data.map(Numbrify);
// If you want to only do a shallow traversal of your object, then pass in
// a second parameter set to false. e.g.
data = [
{"name": "foo", "age": "42"},
{"name": "bar", "age": "32"},
{"name": "baz", "age": "22"}
]
result = Numbrify(data, false)
// Result should equal:
// [
// {"name": "foo", "age": "42"},
// {"name": "foo", "age": "32"},
// {"name": "foo", "age": "22"}
// ]
// Note this has not done anything since the age property is in
// a nested object.
To build this locally, check out the repository, run npm install
and then run npm build
. There is also an npm watch
task that rebuilds on changes to the src file.
The source is written in ES6/ES2015 primarily to take advantage of ES6 modules and the convenient UMD build provided by babel.
FAQs
A utility to convert number-like strings in objects/arrays into numbers.
We found that numbrify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.