Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
dynamic-typing
Advanced tools
When parsing text files, like the ones coming out fromm scientific instruments, it is often useful to convert the obtained strings to their corresponding types.
Indeed when you parse the file while all the fields are text some of them represents in fact numbers or booleans.
This package will try to make the conversion for you using the following rules:
Number(string)
) does not yield to NaN will be converted to numberThis package was optimized for speed and seems to work pretty well. Please don't hesitate to submit bug reports or contribute.
$ npm i dynamic-typing
import { parseString } from 'dynamic-typing';
const result = parseString('0x100');
// result is the number 256
More examples:
parseString('')
➡ ''
parseString(' ')
➡ ' '
parseString('.')
➡ '.'
parseString('0.')
➡ 0
parseString('0.0')
➡ 0
parseString('abc')
➡ 'abc'
parseString('True')
➡ true
parseString('false')
➡ false
parseString('0')
➡ 0
parseString('123')
➡ 123
parseString('123.456')
➡ 123.456
parseString('12e3')
➡ 12000
parseString('0x10')
➡ 16
parseString('0b10')
➡ 2
FAQs
Dynamically type a string
The npm package dynamic-typing receives a total of 787 weekly downloads. As such, dynamic-typing popularity was classified as not popular.
We found that dynamic-typing demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.