Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rambdax

Package Overview
Dependencies
Maintainers
1
Versions
216
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rambdax - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

__tests__/a.js

60

__tests__/test.js

@@ -1,4 +0,40 @@

const R = require("../rambdax")
const R = require("../rambdaxX")
const numArr = [0,1,2,3,4]
const obj = {a:1,b:2}
describe("allPass",()=>{
it("when returns true",()=>{
const conditionArr = [
val => val.a === 1,
val => val.b === 2,
]
expect(
R.allPass(conditionArr,obj)
).toBeTruthy()
})
it("when returns false",()=>{
const conditionArr = [
val => val.a === 1,
val => val.b === 3,
]
expect(
R.allPass(conditionArr,obj)
).toBeFalsy()
})
})
describe("Rambdax",()=>{
describe("all",()=>{
it("when returns true",()=>{
const fn = val => val > -1
expect(R.all(fn,numArr)).toBeTruthy()
})
it("when returns false",()=>{
const fn = val => val > 2
expect(R.all(fn,numArr)).toBeFalsy()
})
})
describe("rangeBy",()=>{
it("",()=>{

@@ -19,2 +55,20 @@ expect(

})
})
})
describe("pickBy",()=>{
it("",()=>{
const input = {a:1,b:2,c:3,d:4}
const fn = val => val > 2
const expectedResult = {c:3,d:4 }
expect(R.pickBy(fn,input)).toEqual(expectedResult)
})
})
describe("omitBy",()=>{
it("",()=>{
const input = {a:1,b:2,c:3,d:4}
const fn = val => val < 3
const expectedResult = {c:3,d:4 }
expect(R.omitBy(fn,input)).toEqual(expectedResult)
})
})

7

package.json
{
"name": "rambdax",
"version": "0.1.0",
"version": "0.2.0",
"description": "rambda",

@@ -29,4 +29,7 @@ "main": "index.js",

"devDependencies": {
"jest": "^19.0.2"
"beautify-benchmark": "^0.2.4",
"benchmark": "^2.1.4",
"jest": "^19.0.2",
"ramda": "^0.23.0"
}
}

@@ -9,11 +9,18 @@ const R = require("rambda")

}
const isInteger = !distance.toString().includes(".")
if(startNum>endNum){
const startNumHolder = startNum
startNum = endNum
endNum = startNumHolder
l(startNum, endNum)
}
const willReturn = [startNum]
const isInteger = !distance.toString().includes(".")
let valueToPush = startNum
if(isInteger){
const loopIndexes = R.range(0,Math.floor((endNum-startNum)/distance))
for(const i of loopIndexes){
valueToPush += distance
l(valueToPush)
valueToPush += distance
willReturn.push(valueToPush)

@@ -27,21 +34,98 @@ }

)(distance.toString())
console.log(startNum.toFixed(decimalLength))
console.log(endNum.toFixed(decimalLength))
const loopIndexes = R.range(0,Math.floor((endNum-startNum)/distance))
for(const i of loopIndexes){
valueToPush = valueToPush+distance
valueToPush = valueToPush+distance
willReturn.push(Number(valueToPush.toFixed(decimalLength)))
}
}
return willReturn
}
function randomIndex(arr){
return arr[ Math.floor(arr.length * Math.random()) ]
function omitBy(fn, obj){
if (obj === undefined) {
return holder => omitBy(fn, holder)
}
const willReturn = {}
for (prop in obj) {
if (!fn(obj[prop],prop)) {
willReturn[ prop ] = obj[ prop ]
}
}
return willReturn
}
// TODO benchmark between the static export vs Object.keys(...)
function pickBy(fn, obj){
if (obj === undefined) {
return holder => pickBy(fn, holder)
}
const willReturn = {}
for (prop in obj) {
if (fn(obj[prop],prop)) {
willReturn[ prop ] = obj[ prop ]
}
}
return willReturn
}
const arg = {inputArgument: false,defaultArgument:true}
function defaultTo({defaultArgument, inputArgument}){
if(inputArgument === undefined){}
return inputArgument === undefined || !(R.type(inputArgument)===R.type(defaultArgument)) ?
defaultArgument :
inputArgument
}
function flip(fnToCurry){
return (...curryArguments)=>{
const len = fnToCurry.length
if(curryArguments[1]===undefined){
if(len > 1){
return (...futureArguments) => {
if(len === 3 && futureArguments.length === 1){
return holder => fnToCurry(holder,futureArguments[0],curryArguments[0])
}
return fnToCurry(...futureArguments.reverse(),curryArguments[0])
}
}
}else if(curryArguments[2]===undefined && len === 3){
return (futureArgument) => fnToCurry(futureArgument, ...curryArguments.reverse())
}
return fnToCurry(...curryArguments.reverse())
}
}
function curry(fnToCurry){
return (...curryArguments)=>{
const len = fnToCurry.length
if(curryArguments[1]===undefined){
if(len > 1){
return (...futureArguments) => {
if(len === 3 && futureArguments.length === 1){
return b => fnToCurry(curryArguments[0],futureArguments[0],b)
}
return fnToCurry(curryArguments[0],...futureArguments)
}
}
}else if(curryArguments[2]===undefined && len === 3){
return (futureArgument) => fnToCurry(...curryArguments,futureArgument)
}
return fnToCurry(...curryArguments)
}
}
exports.curry = curry
exports.defaultTo = defaultTo
exports.flip = flip
exports.omitBy = omitBy
exports.pickBy = pickBy
exports.rangeBy = rangeBy
exports.randomIndex = randomIndex
exports.add = R.add

@@ -93,2 +177,2 @@ exports.adjust = R.adjust

exports.update = R.update
exports.values = R.values
exports.values = R.values

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc