onno-react
Advanced tools
Comparing version 0.4.3 to 0.4.4
@@ -15,2 +15,3 @@ "use strict" | ||
const IGNORE = /\s|\d+\.\d+/ | ||
const NUMBER = /^-?(\d*\.)?\d+$/ | ||
const push = Array.prototype.push | ||
@@ -23,9 +24,11 @@ const isArray = Array.isArray | ||
const isPlainObject = (x) => !!x && isObject(x) && !isArray(x) | ||
const isNumber = isType("number") | ||
const isString = isType("string") | ||
const isUnitless = (x) => isNumber(x) && !!x | ||
const isTypeNumber = isType("number") | ||
const isNumber = (x) => isTypeNumber(x) && !isNaN(x) | ||
const isNumberLike = (x) => isNumber(x) || (isString(x) && NUMBER.test(x)) | ||
const isUnitless = (x) => isNumberLike(x) && !!+x | ||
const isFraction = (x) => isUnitless(x) && x > -1 && x < 1 | ||
const when = (p) => (f) => (x) => (p(x) ? f(x) : x) | ||
const addPc = when(isFraction)((x) => x * 100 + "%") | ||
const addPx = when(isUnitless)((x) => x + "px") | ||
const addPc = when(isFraction)((x) => x * 100 + "%") | ||
const addRem = when(isUnitless)((x) => x + "rem") | ||
@@ -1013,2 +1016,3 @@ const addPcOrPx = (x) => addPx(addPc(x)) | ||
exports.isNumber = isNumber | ||
exports.isNumberLike = isNumberLike | ||
exports.isObject = isObject | ||
@@ -1015,0 +1019,0 @@ exports.isPlainObject = isPlainObject |
@@ -11,2 +11,3 @@ import { oneOfType, number, string, objectOf, arrayOf } from "prop-types" | ||
const IGNORE = /\s|\d+\.\d+/ | ||
const NUMBER = /^-?(\d*\.)?\d+$/ | ||
const push = Array.prototype.push | ||
@@ -19,9 +20,11 @@ const isArray = Array.isArray | ||
const isPlainObject = (x) => !!x && isObject(x) && !isArray(x) | ||
const isNumber = isType("number") | ||
const isString = isType("string") | ||
const isUnitless = (x) => isNumber(x) && !!x | ||
const isTypeNumber = isType("number") | ||
const isNumber = (x) => isTypeNumber(x) && !isNaN(x) | ||
const isNumberLike = (x) => isNumber(x) || (isString(x) && NUMBER.test(x)) | ||
const isUnitless = (x) => isNumberLike(x) && !!+x | ||
const isFraction = (x) => isUnitless(x) && x > -1 && x < 1 | ||
const when = (p) => (f) => (x) => (p(x) ? f(x) : x) | ||
const addPc = when(isFraction)((x) => x * 100 + "%") | ||
const addPx = when(isUnitless)((x) => x + "px") | ||
const addPc = when(isFraction)((x) => x * 100 + "%") | ||
const addRem = when(isUnitless)((x) => x + "rem") | ||
@@ -1007,2 +1010,3 @@ const addPcOrPx = (x) => addPx(addPc(x)) | ||
isNumber, | ||
isNumberLike, | ||
isObject, | ||
@@ -1009,0 +1013,0 @@ isPlainObject, |
{ | ||
"name": "onno-react", | ||
"license": "MIT", | ||
"version": "0.4.3", | ||
"version": "0.4.4", | ||
"homepage": "https://onnojs.com", | ||
@@ -30,6 +30,6 @@ "description": "Onno propTypes for React", | ||
"@types/prop-types": "15.7.1", | ||
"onno": "0.4.3", | ||
"onno": "0.4.4", | ||
"prop-types": "15.7.2" | ||
}, | ||
"gitHead": "93e5c21887be219e17e88e2cf255b713c03acfd3" | ||
"gitHead": "4addb96e57bac9689264f2018a7c88577011212b" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58727
2162
+ Addedonno@0.4.4(transitive)
- Removedonno@0.4.3(transitive)
Updatedonno@0.4.4