Comparing version 6.3.1 to 6.4.0
@@ -514,2 +514,4 @@ function F() { | ||
return 'Array'; | ||
} else if (typeOf === 'symbol') { | ||
return 'Symbol'; | ||
} else if (input instanceof RegExp) { | ||
@@ -2013,6 +2015,2 @@ return 'RegExp'; | ||
function isPromise(x) { | ||
return ['Async', 'Promise'].includes(type(x)); | ||
} | ||
function tryCatch(fn, fallback) { | ||
@@ -2024,26 +2022,9 @@ if (!isFunction(fn)) { | ||
const passFallback = isFunction(fallback); | ||
if (!isPromise(fn)) { | ||
return (...inputs) => { | ||
try { | ||
return fn(...inputs); | ||
} catch (e) { | ||
return passFallback ? fallback(e, ...inputs) : fallback; | ||
} | ||
}; | ||
} | ||
return (...inputs) => new Promise(resolve => { | ||
fn(...inputs).then(resolve).catch(() => { | ||
if (!passFallback) { | ||
return resolve(fallback); | ||
} | ||
if (!isPromise(fallback)) { | ||
return resolve(fallback(...inputs)); | ||
} | ||
fallback(...inputs).then(resolve); | ||
}); | ||
}); | ||
return (...inputs) => { | ||
try { | ||
return fn(...inputs); | ||
} catch (e) { | ||
return passFallback ? fallback(e, ...inputs) : fallback; | ||
} | ||
}; | ||
} | ||
@@ -2050,0 +2031,0 @@ |
@@ -518,2 +518,4 @@ 'use strict'; | ||
return 'Array'; | ||
} else if (typeOf === 'symbol') { | ||
return 'Symbol'; | ||
} else if (input instanceof RegExp) { | ||
@@ -2017,6 +2019,2 @@ return 'RegExp'; | ||
function isPromise(x) { | ||
return ['Async', 'Promise'].includes(type(x)); | ||
} | ||
function tryCatch(fn, fallback) { | ||
@@ -2028,26 +2026,9 @@ if (!isFunction(fn)) { | ||
const passFallback = isFunction(fallback); | ||
if (!isPromise(fn)) { | ||
return (...inputs) => { | ||
try { | ||
return fn(...inputs); | ||
} catch (e) { | ||
return passFallback ? fallback(e, ...inputs) : fallback; | ||
} | ||
}; | ||
} | ||
return (...inputs) => new Promise(resolve => { | ||
fn(...inputs).then(resolve).catch(() => { | ||
if (!passFallback) { | ||
return resolve(fallback); | ||
} | ||
if (!isPromise(fallback)) { | ||
return resolve(fallback(...inputs)); | ||
} | ||
fallback(...inputs).then(resolve); | ||
}); | ||
}); | ||
return (...inputs) => { | ||
try { | ||
return fn(...inputs); | ||
} catch (e) { | ||
return passFallback ? fallback(e, ...inputs) : fallback; | ||
} | ||
}; | ||
} | ||
@@ -2054,0 +2035,0 @@ |
@@ -520,2 +520,4 @@ (function (global, factory) { | ||
return 'Array'; | ||
} else if (typeOf === 'symbol') { | ||
return 'Symbol'; | ||
} else if (input instanceof RegExp) { | ||
@@ -2019,6 +2021,2 @@ return 'RegExp'; | ||
function isPromise(x) { | ||
return ['Async', 'Promise'].includes(type(x)); | ||
} | ||
function tryCatch(fn, fallback) { | ||
@@ -2030,26 +2028,9 @@ if (!isFunction(fn)) { | ||
const passFallback = isFunction(fallback); | ||
if (!isPromise(fn)) { | ||
return (...inputs) => { | ||
try { | ||
return fn(...inputs); | ||
} catch (e) { | ||
return passFallback ? fallback(e, ...inputs) : fallback; | ||
} | ||
}; | ||
} | ||
return (...inputs) => new Promise(resolve => { | ||
fn(...inputs).then(resolve).catch(() => { | ||
if (!passFallback) { | ||
return resolve(fallback); | ||
} | ||
if (!isPromise(fallback)) { | ||
return resolve(fallback(...inputs)); | ||
} | ||
fallback(...inputs).then(resolve); | ||
}); | ||
}); | ||
return (...inputs) => { | ||
try { | ||
return fn(...inputs); | ||
} catch (e) { | ||
return passFallback ? fallback(e, ...inputs) : fallback; | ||
} | ||
}; | ||
} | ||
@@ -2056,0 +2037,0 @@ |
{ | ||
"name": "rambda", | ||
"version": "6.4.0", | ||
"scripts": { | ||
"out": "jest scripts/all-scripts/all-scripts.spec.js", | ||
"x": "WITH_RAMBDAX=ON jest scripts/all-scripts/all-scripts.spec.js", | ||
"docs": "cd ../rambda-scripts&&yarn highlighter", | ||
"readme": "jest scripts/populate-readme-data/populate-readme-data.spec.js", | ||
"toolbelt": "cd ../rambda-scripts&&yarn toolbelt", | ||
"immutable": "cd ../rambda-scripts&&yarn immutable", | ||
"usedby": "cd ../rambda-scripts&&yarn usedby", | ||
"lint": "yarn lint:js&&yarn lint:ts", | ||
"lint:ts": "cd scripts/lint-ts-files&&node lint-typings-tests.js", | ||
"lint:js": "jest scripts/lint/lint.spec.js", | ||
"docsify": "docsi init ./docs", | ||
"build": "yarn build:main&&yarn build:web", | ||
"build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.js", | ||
"build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.js", | ||
"parse": "node scripts/parse-package-json/parse-package-json", | ||
"new": "node scripts/add-new-method/add-new-method.js", | ||
@@ -8,48 +24,36 @@ "test": "jest source -u --bail=false", | ||
"cover": "yarn typings&&yarn cover:spec", | ||
"out": "maided out", | ||
"x": "maided rambdax", | ||
"benchmark": "jest scripts/run-benchmarks/run-benchmarks.spec.js", | ||
"benchmarkx": "jest scripts/run-benchmarks/run-complex-benchmarks.spec.js", | ||
"toolbelt": "maided toolbelt", | ||
"build": "maided build", | ||
"lint": "maided lint", | ||
"readme": "maided readme", | ||
"docs": "docsify init ./docs", | ||
"typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source", | ||
"fix": "mkdir $HOME/.dts/perf -p" | ||
}, | ||
"typings": "./index.d.ts", | ||
"main": "./dist/rambda.js", | ||
"version": "6.3.1", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/core": "7.11.6", | ||
"@babel/plugin-proposal-object-rest-spread": "7.11.0", | ||
"@babel/preset-env": "7.11.5", | ||
"@types/fs-extra": "9.0.1", | ||
"@types/jest": "26.0.14", | ||
"@types/ramda": "0.27.7", | ||
"@babel/core": "7.12.3", | ||
"@babel/plugin-proposal-object-rest-spread": "7.12.1", | ||
"@babel/preset-env": "7.12.1", | ||
"@rollup/plugin-babel": "5.2.1", | ||
"@rollup/plugin-commonjs": "16.0.0", | ||
"@rollup/plugin-json": "4.1.0", | ||
"@rollup/plugin-node-resolve": "10.0.0", | ||
"@rollup/plugin-replace": "2.3.4", | ||
"@types/fs-extra": "9.0.4", | ||
"@types/jest": "26.0.15", | ||
"@types/ramda": "0.27.32", | ||
"combinate": "1.1.1", | ||
"cross-env": "7.0.2", | ||
"dtslint": "4.0.4", | ||
"dtslint": "4.0.5", | ||
"fs-extra": "9.0.1", | ||
"helpers-fn": "0.7.0", | ||
"helpers-fn": "1.0.0", | ||
"is-ci": "2.0.0", | ||
"jest": "26.4.2", | ||
"jest": "26.6.3", | ||
"jest-extended": "0.11.5", | ||
"lint-fn": "2.10.0", | ||
"lodash": "4.17.19", | ||
"maided": "0.1.3", | ||
"rambdax": "4.1.0", | ||
"ramda": "0.27.0", | ||
"rollup": "2.28.2", | ||
"rollup-plugin-babel": "4.4.0", | ||
"lint-fn": "2.12.1", | ||
"lodash": "4.17.20", | ||
"rambdax": "7.0.1", | ||
"ramda": "0.27.1", | ||
"rollup": "2.33.1", | ||
"rollup-plugin-cleanup": "3.2.1", | ||
"rollup-plugin-commonjs": "10.1.0", | ||
"rollup-plugin-json": "4.0.0", | ||
"rollup-plugin-node-resolve": "5.2.0", | ||
"rollup-plugin-replace": "2.2.0", | ||
"rollup-plugin-sourcemaps": "0.6.2", | ||
"string-fn": "2.12.2", | ||
"typescript": "4.0.3" | ||
"rollup-plugin-sourcemaps": "0.6.3", | ||
"string-fn": "3.1.0", | ||
"typescript": "4.2.0-dev.20201113" | ||
}, | ||
@@ -82,7 +86,5 @@ "jest": { | ||
"module": "./dist/rambda.esm.js", | ||
"main": "./dist/rambda", | ||
"umd": "./dist/rambda.umd.js", | ||
"sideEffects": false, | ||
"commitLabels": [ | ||
"rambdax" | ||
], | ||
"keywords": [ | ||
@@ -89,0 +91,0 @@ "ramda", |
import combinate from 'combinate' | ||
import { equals, filter, forEach, map, omit, switcher, type } from 'rambdax' | ||
import { | ||
equals, | ||
filter, | ||
forEach, | ||
init, | ||
last, | ||
omit, | ||
switcher, | ||
type, | ||
} from 'rambdax' | ||
@@ -42,7 +51,11 @@ const omitOk = omit('ok') | ||
function executeSync(fn, inputs){ | ||
function executeSync( | ||
fn, inputs, returnsFunctionFlag | ||
){ | ||
let result = PENDING | ||
let error = { ok : false } | ||
try { | ||
result = fn(...inputs) | ||
result = returnsFunctionFlag ? | ||
fn(...init(inputs))(last(inputs)) : | ||
fn(...inputs) | ||
} catch (e){ | ||
@@ -58,7 +71,11 @@ error = parseError(e) | ||
async function executeAsync(fn, inputs){ | ||
async function executeAsync( | ||
fn, inputs, returnsFunctionFlag | ||
){ | ||
let result = PENDING | ||
let error = { ok : false } | ||
try { | ||
result = await fn(...inputs) | ||
result = returnsFunctionFlag ? | ||
await fn(...init(inputs))(last(inputs)) : | ||
await fn(...inputs) | ||
} catch (e){ | ||
@@ -74,8 +91,9 @@ error = parseError(e) | ||
export function profileMethod( | ||
export function profileMethod({ | ||
firstInput, | ||
secondInput = undefined, | ||
thirdInput = undefined, | ||
fn | ||
){ | ||
returnsFunctionFlag = false, | ||
fn, | ||
}){ | ||
const combinationsInput = filter(Boolean, { | ||
@@ -97,3 +115,5 @@ firstInput, | ||
test(getTestTitle(...inputs), () => { | ||
const { result, error } = executeSync(fn, inputs) | ||
const { result, error } = executeSync( | ||
fn, inputs, returnsFunctionFlag | ||
) | ||
@@ -113,2 +133,3 @@ expect({ | ||
thirdInput = undefined, | ||
returnsFunctionFlag = false, | ||
fn, | ||
@@ -131,3 +152,7 @@ }){ | ||
test(getTestTitle(...inputs), async () => { | ||
const { result, error } = await executeAsync(fn, inputs) | ||
const { result, error } = await executeAsync( | ||
fn, | ||
inputs, | ||
returnsFunctionFlag | ||
) | ||
@@ -143,7 +168,14 @@ expect({ | ||
export function compareToRamda(fn, fnRamda){ | ||
export function compareToRamda( | ||
fn, fnRamda, returnsFunctionFlag | ||
){ | ||
return (...inputs) => { | ||
const { result, error } = executeSync(fn, inputs) | ||
const { result: ramdaResult, error: ramdaError } = executeSync(fnRamda, | ||
inputs) | ||
const { result, error } = executeSync( | ||
fn, inputs, returnsFunctionFlag | ||
) | ||
const { result: ramdaResult, error: ramdaError } = executeSync( | ||
fnRamda, | ||
inputs, | ||
returnsFunctionFlag | ||
) | ||
@@ -208,38 +240,4 @@ const toReturn = { | ||
const list = [ 1, 2, 3, 4 ] | ||
export const getTestTitle = (...inputs) => inputs.map(type).join(' | ') | ||
export function show(input){ | ||
if (process.env.WALLABY === 'ON'){ | ||
return input | ||
} | ||
const typeInput = type(input) | ||
if ([ 'Promise', 'Async' ].includes(typeInput)){ | ||
return '' | ||
} | ||
if (typeInput === 'Array'){ | ||
if (input.length === 0) return '[]' | ||
return `[${ input.map(show).join(', ') }]` | ||
} | ||
if (typeInput === 'Object'){ | ||
if (Object.keys(input).length === 0) return '{}' | ||
return JSON.stringify(map(show, input)) | ||
} | ||
if ([ 'Boolean', 'Number', 'String' ].includes(typeInput)){ | ||
return input | ||
} | ||
if ([ 'Null', 'Undefined' ].includes(typeInput)){ | ||
return typeInput.toLowerCase() | ||
} | ||
return input.toString() | ||
} | ||
export const getTestTitle = (...inputs) => | ||
inputs.map(x => `${ type(x) } ${ show(x) }`).join(' | ') | ||
export const compareCombinations = ({ | ||
@@ -249,2 +247,3 @@ firstInput, | ||
thirdInput = undefined, | ||
returnsFunctionFlag = false, | ||
setCounter = () => {}, | ||
@@ -279,3 +278,5 @@ callback = x => {}, | ||
const combinations = combinate(combinationsInput) | ||
const compareOutputs = compareToRamda(fn, fnRamda) | ||
const compareOutputs = compareToRamda( | ||
fn, fnRamda, returnsFunctionFlag | ||
) | ||
@@ -296,2 +297,6 @@ afterAll(() => callback(counter)) | ||
if (!compared.ok){ | ||
// if (compared.label === RESULTS_MISMATCH){ | ||
// const log = {combination, } | ||
// console.log(log); | ||
// } | ||
increaseCounter(compared) | ||
@@ -306,24 +311,1 @@ expect({ | ||
} | ||
/* | ||
describe("brute force", () => { | ||
let counter = 0; | ||
afterAll(() => { | ||
console.log({ counter }); | ||
}); | ||
compareCombinations({ | ||
firstInput: possibleRules, | ||
setCounter: () => counter++, | ||
callback: errorsCounter => { | ||
expect( | ||
errorsCounter | ||
).toMatchInlineSnapshot() | ||
}, | ||
secondInput: possibleIterables, | ||
fn: evolve, | ||
fnRamda: evolveRamda, | ||
}); | ||
}); | ||
*/ |
@@ -1,6 +0,5 @@ | ||
export function add(a, b) { | ||
if (arguments.length === 1) | ||
return (_b) => add(a, _b); | ||
export function add(a, b){ | ||
if (arguments.length === 1) return _b => add(a, _b) | ||
return Number(a) + Number(b); | ||
return Number(a) + Number(b) | ||
} |
import { isFunction } from './isFunction' | ||
import { isPromise } from './isPromise' | ||
@@ -10,3 +9,2 @@ export function tryCatch(fn, fallback){ | ||
if (!isPromise(fn)){ | ||
return (...inputs) => { | ||
@@ -19,20 +17,2 @@ try { | ||
} | ||
} | ||
return (...inputs) => | ||
new Promise(resolve => { | ||
fn(...inputs) | ||
.then(resolve) | ||
.catch(() => { | ||
if (!passFallback){ | ||
return resolve(fallback) | ||
} | ||
if (!isPromise(fallback)){ | ||
return resolve(fallback(...inputs)) | ||
} | ||
fallback(...inputs).then(resolve) | ||
}) | ||
}) | ||
} |
@@ -18,2 +18,4 @@ import { _isArray } from './_internals/_isArray' | ||
return 'Array' | ||
} else if (typeOf === 'symbol'){ | ||
return 'Symbol' | ||
} else if (input instanceof RegExp){ | ||
@@ -20,0 +22,0 @@ return 'RegExp' |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
1204204
28
19007
26490
0