profile
viewpoint
Henrik Lundgren henriklundgren Sweden

henriklundgren/explainys.js 4

jQuery plugin to add sidenotes/footnotes.

henriklundgren/angular-pagetitle 0

Angular directive for the HTML title tag

henriklundgren/browserdb 0

IndexedDB wrapper

henriklundgren/Buttons 0

A CSS button library built using Sass and Compass

henriklundgren/css-parse 0

CSS parser for Node.js

henriklundgren/deck 0

Xfwm window theme

issue closedramda/ramda

Unexpected behavior when using R.any

I am noticing some behavior when using R.any that I wouldn't expect. Here's the scenario:

const person = {name: 'hasan'} const people = [person]

any(equals)(people) // I am expecting this to return false, but it returns true. any(equals())(people) // I am expecting this to return false, but it returns true.

any(equals(undefined))(people) // I am expecting this to return false, and as expected it returns false any(equals(person))(people) // I am expecting this to return true, and as expected it returns true

It seems if you do one of the following:

  1. Provide the function definition as the first argument to R.any
  2. Invoke the function with no argument as the first argument to R.any

It doesn't actual do the comparison and returns true by default?

closed time in 10 hours

hmust92

issue commentramda/ramda

Unexpected behavior when using R.any

Thanks a lot @Bradcomp and @CrossEye ! I think I was confusing myself because I expected the function to return a function definition, but forgot that R.any will run a JS truthy check on it. Thanks so much for the response. I'll close this issue as I have understood the underlying mechanics of the function better now.

hmust92

comment created time in 10 hours

issue openedramda/ramda

Add `splitEvenly`

I'd love seeing a version of splitEvery that excludes the last chunk it it'd be shorter than others. My particular use case is I don't want to display the final week of a given time period if it's missing some days, but I think there are several UI (and others!) use cases for that.

My current solution is:

export const splitEvenly = <T>(data: Array<T>, n: number): Array<Array<T>> =>
  R.splitEvery(n, data.slice(0, Math.floor(data.length / n) * n))

created time in 19 hours

issue commentramda/ramda

Better error messaging and type-checking

@adispring

passing string instead of array as R.path first argument;

If someone cannot read the documentation, you can always tell him to download TS :)

CrossEye

comment created time in 20 hours

issue commentramda/ramda

Unexpected `pathOr` return value while path is [-1] (in version 0.27)

hety @CrossEye how with this research? Shall we remove negative int handling from prop/path? I can take care of it

Andrey-Bazhanov

comment created time in 20 hours

startedkubernetes/kubernetes

started time in 2 days

issue commentramda/ramda

Comparing to compose+reduce, what's the benefit transduce give us?

@CrossEye , Thanks very much. You just make me begin to realize the value of transducers, which confused me so long before now.

One of the places they shine the most, though, is when you include take(n) on a potential infinite stream.

And as describes in Clojure:

Because transducers are decoupled from input or output sources, they can be used in many different processes - collections, streams, channels, observables, etc.

With transducers, we can process different type of collection in the same way, as follows:

const isEven = (x) => x % 2 === 0;

const transducer = R.compose(
  R.take(6),
  R.map(R.prop("count")),
  R.filter(isEven)
);

const sum = R.transduce(transducer, R.add, 0);

const arr = R.map((x) => ({ count: x }), [0, 1, 2, 3, 4, 5, 6, 7, 8]);
function* naturalGenerator() {
  let i = 0;
  while (true) {
    yield { count: i++ };
  }
}
const arrSum = sum(arr);
const generatorSum = sum(naturalGenerator());

console.log(arrSum); // 6
console.log(generatorSum); // 6

Without transducers, we have to implement different methods for different kinds of Data Structures.

Thanks again.

adispring

comment created time in 3 days

issue commentramda/ramda

Comparing to compose+reduce, what's the benefit transduce give us?

Well, the whole point is to skip the intermediate results. That's all transducers are really about. There's a good argument that they are not worth the complexity in a library like Ramda. One of the places they shine the most, though, is when you include take(n) on a potential infinite stream. You get to write the simple transformations, filters, etc., and not have to do any particular gymnastics in order to collect the first n values.

adispring

comment created time in 3 days

issue openedramda/ramda

Comparing to compose+reduce, what's the benefit transduce give us?

Except no intermediate results, dose transduce have other advantage?

created time in 3 days

Pull request review commentacdlite/recompose

Permit react 17

     "most": "^1.0.2",     "prettier": "^1.2.2",     "prop-types": "^15.6.1",-    "react": "^16.3.1",+    "react": "^17.0.1",

It's likely not wise to bump this so that anything between 16.3.1 and 17.0.1 isn't allowed.

cesine

comment created time in 3 days

Pull request review commentacdlite/recompose

Permit react 17

     "glamor": "^3.0.0-3",     "glamor-reset": "^3.0.0-2",     "hoist-non-react-statics": "^2.0.0",-    "react": "^15.6.1",+    "react": "^17.0.1",

It's likely not wise to bump this so that anything between 16.3.1 and 17.0.1 isn't allowed.

cesine

comment created time in 3 days

startedcvdlab/react-planner

started time in 4 days

PR opened acdlite/recompose

Permit react 17

How this was tested

$ yarn install
$ yarn run lint
yarn run v1.19.1
$ eslint scripts src

~/recompose/src/packages/recompose/__tests__/setPropTypes-test.js
  9:23  warning  Using propTypes from another component is not safe because they may be removed in production builds  react/forbid-foreign-prop-types

~/recompose/src/packages/recompose/__tests__/setStatic-test.js
  11:23  warning  Using propTypes from another component is not safe because they may be removed in production builds  react/forbid-foreign-prop-types

~/recompose/src/packages/recompose/__tests__/toClass-test.js
  29:24  warning  Using propTypes from another component is not safe because they may be removed in production builds  react/forbid-foreign-prop-types

~/recompose/src/packages/recompose/onlyUpdateForPropTypes.js
  7:35  warning  Using propTypes from another component is not safe because they may be removed in production builds  react/forbid-foreign-prop-types

~/recompose/src/packages/recompose/toClass.js
  10:42  warning  Using propTypes from another component is not safe because they may be removed in production builds  react/forbid-foreign-prop-types

✖ 5 problems (0 errors, 5 warnings)

(node:26095) [ESLINT_LEGACY_OBJECT_REST_SPREAD] DeprecationWarning: The 'parserOptions.ecmaFeatures.experimentalObjectRestSpread' option is deprecated. Use 'parserOptions.ecmaVersion' instead. (found in "node_modules/eslint-config-airbnb-base/index.js")
✨  Done in 3.32s.


$ yarn test
yarn run v1.19.1
$ jest && flow check && cross-env SNAPSHOT=match npm run build:recompose

 RUNS  src/packages/recompose/__tests__/withStateHandlers-test.js
 RUNS  src/packages/recompose/__tests__/withPropsOnChange-test.js
 RUNS  src/packages/recompose/__tests__/withHandlers-test.js
 RUNS  src/packages/recompose/__tests__/componentFromStream-test.js
 RUNS  src/packages/recompose/__tests__/withReducer-test.js
 RUNS  src/packages/recompose/__tests__/fromRenderProps-test.js
 RUNS  src/packages/recompose/__tests__/toClass-test.js
 RUNS  src/packages/recompose/__tests__/withState-test.js
 RUNS  src/packages/recompose/__tests__/setObservableConfig-test.js
 RUNS  src/packages/recompose/__tests__/branch-test.js
 PASS  src/packages/recompose/__tests__/componentFromStream-test.js.js
 PASS  src/packages/recompose/__tests__/setObservableConfig-test.js (5.155s)
 PASS  src/packages/recompose/__tests__/withPropsOnChange-test.js (7.928s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/withStateHandlers-test.js (7.971s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/shallowEqual-test.js
 PASS  src/packages/recompose/__tests__/branch-test.js (7.965s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/withContext-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/withState-test.js (8.038s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/withHandlers-test.js (8.16s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/withReducer-test.js (8.082s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/toClass-test.js (8.174s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/fromRenderProps-test.js (8.128s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/onlyUpdateForPropTypes-test.js (8.302s)
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/shouldUpdate-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/withProps-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/defaultProps-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/pure-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/createEventHandler-test.js
 PASS  src/packages/recompose/__tests__/hoistStatics-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/onlyUpdateForKeys-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/getDisplayName-test.js
 PASS  src/packages/recompose/__tests__/flattenProp-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/compose-test.js
 PASS  src/packages/recompose/__tests__/createSink-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/mapProps-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/isClassComponent-test.js
 PASS  src/packages/recompose/__tests__/mapPropsStream-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/renderComponent-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/nest-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/toRenderProps-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/renameProps-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/componentFromProp-test.js
 PASS  src/packages/recompose/__tests__/lifecycle-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/renameProp-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/renderNothing-test.js
 PASS  src/packages/recompose/__tests__/setPropTypes-test.js
 PASS  src/packages/recompose/__tests__/wrapDisplayName-test.js
 PASS  src/packages/recompose/__tests__/setStatic-test.js
 PASS  src/packages/recompose/__tests__/setDisplayName-test.js
 PASS  src/packages/recompose/__tests__/getContext-test.js
 PASS  src/packages/recompose/__tests__/mapPropsStreamWithConfig-test.js
  ● Console

    console.warn node_modules/react/cjs/react.development.js:220
      Warning: React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.

 PASS  src/packages/recompose/__tests__/componentFromStreamWithConfig-test.js

Test Suites: 42 passed, 42 total
Tests:       97 passed, 97 total
Snapshots:   0 total
Time:        11.033s
Ran all test suites.
Found 0 errors
npm WARN lifecycle The node binary used for scripts is /var/folders/z5/pq552q7d5hz7_m1887s3v_z80000gp/T/yarn--1606181196241-0.7648074009398107/node but npm is using node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> recompose-build@ build:recompose ~/recompose
> cross-env PACKAGE_NAME=recompose rollup --config scripts/rollup.config.js


./src/packages/recompose/index.js → lib/packages/recompose/dist/Recompose.umd.js...
Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade caniuse-lite browserslist`
created lib/packages/recompose/dist/Recompose.umd.js in 1.3s

./src/packages/recompose/index.js → lib/packages/recompose/dist/Recompose.min.js...
created lib/packages/recompose/dist/Recompose.min.js in 946ms

./src/packages/recompose/index.js → lib/packages/recompose/dist/Recompose.cjs.js...
created lib/packages/recompose/dist/Recompose.cjs.js in 298ms

./src/packages/recompose/index.js → lib/packages/recompose/dist/Recompose.esm.js...
created lib/packages/recompose/dist/Recompose.esm.js in 1s
✨  Done in 22.45s. 
+9 -10

0 comment

5 changed files

pr created time in 5 days

pull request commentramda/ramda

chore: rename _iterableReduce to _iteratorReduce

@adispring:

Yes, iterator will change itself's state when calling next(). So, let's remove iterator from reduce?

That's my current thought. But I believe this needs significantly more deliberation.

Anyone from @ramda/core want to chime in? How about @buzzdecafe or @kevinbeaty ?

adispring

comment created time in 5 days

pull request commentramda/ramda

chore: rename _iterableReduce to _iteratorReduce

Yes, iterator will change itself's state when calling next(). So, let's remove iterator from reduce?

adispring

comment created time in 5 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

@SurmaAa:

I wrote an article on this in the early days of Ramda. Let me know if that helps make it clear.

SurmaAa

comment created time in 5 days

pull request commentramda/ramda

chore: rename _iterableReduce to _iteratorReduce

I think this raises a much broader point.

Should we be accepting iterators? That strikes me very much against the spirit of Ramda. Accepting iterables keeps the mutation inside our function. But accepting iterators seems to lead to potential problems with referential transparency. Iterators are inherently stateful, and I really don't like this:

const arr= [1, 2, 3]
const foo = arr [Symbol.iterator] ()

reduce (add, 0, foo) //=> 6
reduce (add, 0, foo) //=> 0  // Whoa!!!

With iterables, this just makes sense:

const bar = {
  [Symbol.iterator]: (i = 0) => ({
    next: () => i < 3 ? {done: false, value: ++i} : {done: true}      
  })
}

reduce (add, 0, bar) //=> 6
reduce (add, 0, bar) //=> 6

I believe we need to think this through pretty carefully.

adispring

comment created time in 5 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

@CrossEye Okay. Therefore, I will really appreciate if you could show me these useful behaviors, a real life example should work best. I'm just curious.

SurmaAa

comment created time in 6 days

PR opened ramda/ramda

chore: rename _iterableReduce to _iteratorReduce

According to MDN document, iterable an iterator are two different thing:

  • iterable is an object that can create an iterator by @@iterator method;
  • iterator is an object that implements a next() method, which can produce a sequence of values;

So in the _reduce's implementation, _iterableReduce processes iterator instead of iterable actually. I think it's better to be called as _iteratorReduce.

+5 -5

0 comment

1 changed file

pr created time in 7 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

@SurmaAA:

Don't you think it should behave like in native js functions?

Although there has been some controversy about this over the years, it's very hard to see when that is useful behavior. And I much prefer this consistency:

f .length                //=> 4
const g = curry (f)
g.length                 //=> 4
g('a', 'b', 'c') .length //=> 1
g('a', 'b') .length      //=> 2
g('a') .length           //=> 3
g() .length              //=> 4

There are reasonable arguments that Ramda has too much magic in its currying, but we have found it useful behavior over the years.

SurmaAa

comment created time in 8 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

By extension, if a function is called with no parameters, it will return a function that takes all the parameters, i.e. the original function.

Don't you think it should behave like in native js functions? e.g.

const add = (a) => (b) => a + b;
const addTo5 = add(5); 
addTo5() // returns NaN (instead of returning addTo5 like in ramda)
SurmaAa

comment created time in 9 days

issue commentramda/ramda

Remove ES Module build with a source change

I don't think there would be a lot of implications - can't quite see any dangers from any side. Just tags would be created for commits that wouldn't exist in the main trunk of the git history but this doesn't seem to be inherently bad, those are not that uncommon situations.

Pyrolistical

comment created time in 9 days

issue commentramda/ramda

Remove ES Module build with a source change

@Andarist: I like your thinking. I have no real idea what other implications this would have, and would have to think about it and play around a bit. (Unfortunately my main computer died and until the new year, I'm probably stuck coding on a tablet, so I don't expect to do too much myself for the next six weeks or so.)

Pyrolistical

comment created time in 9 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

Currying is pretty core to how Ramda treats parameters. It allows us to pass in one parameter at a time instead of all at once.

In JS terms, it's basically based on checking arguments.length, but the concept exists across languages.

If we call a function with less than the full number of parameters, the function will return a new function with the arguments passed in partially applied, ready to accept the remainder of the parameters.

So for instance if we call R.add with one parameter, we get a function that takes the one remaining parameter.

By extension, if a function is called with no parameters, it will return a function that takes all the parameters, i.e. the original function.

Since undefined is a value in JS, you can pass it in as a parameter. So f(undefined) will return a function with undefined partially applied as the first parameter. When we call f() on the other hand, we aren't passing in any values, and so there is nothing to partially apply.

SurmaAa

comment created time in 10 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

You can see the reason why curriedFn() not equals to curriedFn(undefined) here: #3006 (comment)

I know. I read the source but curriedFn() !== curriedFn(undefined) doesn't make sense for me. Do you know what was the reason of this implementation?

SurmaAa

comment created time in 10 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

You can see the reason why curriedFn() not equals to curriedFn(undefined) here: https://github.com/ramda/ramda/issues/3006#issuecomment-610475350

SurmaAa

comment created time in 10 days

issue commentramda/ramda

R.when doesn't call a 'whenTrueFn' when has no function before itself

I think it's due to when

const runWithoutPipe = R.when(()=>true, whenTrue)
runWithoutPipe(undefined) // true 
runWithoutPipe() // returns function

Why runWithoutPipe(undefined) returns true and runWithoutPipe() // returns itself? Then I can do runWithoutPipe()(undefined) // returns true It is a bug?

SurmaAa

comment created time in 10 days

issue commentramda/ramda

Remove ES Module build with a source change

I've just wanted to chime in here again after thinking about this problem in a different repository. I believe that the best thing would be to keep build artifacts ignored on the branches but they could be added to git on a detached HEAD, just before tagging that detached HEAD. It would kinda let library authors have cake and eat it too. That way anyone could use dist files directly from the tagged commits and we wouldn't have to worry about people using source files directly as they very often are not for public consumption.

Pyrolistical

comment created time in 10 days

fork ronag/busboy

A streaming parser for HTML form data for node.js

fork in 10 days

issue openedramda/ramda

R.when doesn't call a function when has no function before itself

Hey, got a problem that I must pass e.g. R.identity as a argument to pipe before my R.when otherwise R.when final arg (in this case open) isn't called even if conditions are true. I don't know if it's ramda bug or just code fault but I can't debug that

Code Example:

import { useEffect } from 'react'
import { always, complement, pipe, both, when, isEmpty } from 'ramda' 
import { lastNotIsIdle } from 'common' // last item in array != 'idle'
import { noop } from 'lodash' // returns always undefined

// show: boolean
// statesHistory: string[]
// open: function

export const useOpenWhenDetectUpdateProcess = (show, statesHistory, open) => {
  const isClosed = complement(always(show))
  const isUpdateProcessOn = pipe(
    startWith(statesHistory),
    both(lastNotIsIdle, complement(isEmpty)),
  )

  const shouldOpen = both(isClosed, isUpdateProcessOn)

  useEffect(
    pipe(
      // if nothing is here then `open` is not called, but if I pass here e.g. `R.identity` or `() => undefined` it starts working 🤔 
      when(shouldOpen, open),
      noop,
    ),
    [show, statesHistory],
  )
}

created time in 10 days

more