Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
baiji-normalizer
Advanced tools
Readme
A smart value type converter for Baiji
npm install baiji-normalizer
// Built-in Types
// number, string, date, boolean, object, any
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
# Normalizer.convertArray(val, opts) => convert val to array
FAQs
Baiji Normalizer
The npm package baiji-normalizer receives a total of 80 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.