Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
baiji-normalizer
Advanced tools
A smart value type converter for Baiji
npm install baiji-normalizer
// Built-in Types
// number, string, date, boolean
var Normalizer = require('baiji-normalizer');
// Number
Normalizer.convert('1', 'number') // => 1
Normalizer.convert(1, 'number') // => 1
Normalizer.convert('', 'number') // => null
Normalizer.convert(undefined, 'number') // => undefined
Normalizer.convert(null, 'number') // => null
// String
Normalizer.convert('1', 'string') // => '1'
Normalizer.convert(1, 'string') // => '1'
Normalizer.convert('', 'string') // => ''
Normalizer.convert(undefined, 'string') // => undefined
Normalizer.convert(null, 'string') // => null
// Date
Normalizer.convert('1', 'date') // => Thu Jan 01 1970 08:00:00 GMT+0800 (CST)
Normalizer.convert(1, 'date') // => Thu Jan 01 1970 08:00:00 GMT+0800 (CST)
Normalizer.convert('', 'date') // => Invalid Date
Normalizer.convert(undefined, 'date') // => undefined
Normalizer.convert(null, 'date') // => null
// Boolean
Normalizer.convert(undefined, 'boolean') // => undefined
Normalizer.convert('1', 'boolean') // => true
Normalizer.convert(1, 'boolean') // => true
Normalizer.convert(0, 'boolean') // => false
Normalizer.convert(NaN, 'boolean') // => false
Normalizer.convert('', 'boolean') // => false
Normalizer.convert('undefined', 'boolean') // => false
Normalizer.convert('null', 'boolean') // => false
Normalizer.convert('0', 'boolean') // => false
Normalizer.convert(null, 'boolean') // => false
// Handle array type
Normalizer.convert(1, ['number']) // => [1]
Normalizer.convert(true, ['boolean']) // => [true]
var Normalizer = require('baiji-normalizer');
// add new
Normalizer.define('regexp', function(val, opts) {
if (val === undefined || val === null || val instanceof RegExp) return val;
val = String(val);
return new RegExp(val.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&'));
});
// overwrite existing
Normalizer.define('boolean', function(val, opts) {
return Boolean(val);
});
# Normalizer.undefine(type, converterFn) => undefine a converter
# Normalizer.canConvert(type) => check if a type can be converted
# Normalizer.getConverter(type) => get a specific converter
FAQs
Baiji Normalizer
The npm package baiji-normalizer receives a total of 85 weekly downloads. As such, baiji-normalizer popularity was classified as not popular.
We found that baiji-normalizer 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.