Coder Social home page Coder Social logo

immutable-ext's People

Contributors

lyncee59 avatar nminhnguyen avatar ron-liu avatar sha49 avatar tomphilbin avatar wking-io avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

immutable-ext's Issues

Ergonomics question

I have a DX question: should people import from immutable-ext, or use it as a "polyfill" sort of?

index:

import 'immutable-ext';

import Application from './Application';

Application.start();

Application:

import Task from 'folktale/concurrency/task';
import { Map } from 'immutable';

Map({ thing: 'value' }).traverse(Task.of, x => Http.get(x))

Given the wide range of experience and variable value this adds based on what people work on (not everybody uses immutablejs to the same extent in our applications), I feel like asking everybody to import List and Map from immutable-ext, but the rest from immutablejs might annoying to ask, and one of those nits during code review that are going to make me extremely disliked :D. Thoughts?

Installing this library does not bring in immutablejs dependency

When I run npm i immutable-ext

Expected Behaviour

[email protected] /Users/amiterandole/Documents/current/javascript/composable-functional-javascript
└── [email protected]

Actual Behaviour

[email protected] /Users/amiterandole/Documents/current/javascript/composable-functional-javascript
├── UNMET PEER DEPENDENCY immutable@*
└── [email protected]

Currently I manually install immutable first and then the install works

Deprecation Warning

~/repos/sandbox/javascript/src [master] % node --trace-deprecation script.js
(node:59243) [DEP0128] DeprecationWarning: Invalid 'main' field in '/Users/onosendi/repos/sandbox/javascript/node_modules/immutable-ext/package.json' of 'dist/index.js'. Please either fix that or report it to the module author
at tryPackage (node:internal/modules/cjs/loader:364:15)
at Function.Module._findPath (node:internal/modules/cjs/loader:566:18)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/Users/onosendi/repos/sandbox/javascript/src/script.js:1:18)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)

Babel not transpiling.

Hi there, first off thanks for this great little lib and all the videos!

I am running into a compilation error while trying to minify immutable-ext related code

Failed to minify the code from this file:

 	./node_modules/immutable-ext/index.js:2```

Here are the simple steps to reproduce it

npm i create-react-app
create-react-app demo2
cd demo2
yarn build
yarn add immutable immutable-ext

then add 

import { List } from 'immutable-ext'
List(['Hey', 'Ho', 'Lets Go!'])

to index.js

yarn build

Cheers!

What's the roadmap and how ready is this project for production?

I've been very interested in using immutablejs in combination with a complete functional interface. I'm actually shocked to find this. I had searched a bunch and found like 1 or 2 weekend projects implementing immutablejs. How ready is this to be used? What should one's expectations be?

traverse run in reverse order

I tried to do: given a list of functions which return tasks, run given tasks sequentially, and return the task of a list of returned values.

For the following case, I expected to output: 1 2 3, but it outputted: 3 2 1.

const {task, of} = require('folktale/concurrency/task') // using folktale 2.x
const buildTask = (n, ms) => task(({resolve}) => setTimeout( ()=> {
		console.log(n)
		resolve(n)
	}, ms
))

test('sequentially', async () => {
	const {List} = require('immutable-ext')
	
	await List.of(
		() => buildTask(1, 500),
 	      	() => buildTask(2, 0),
		() => buildTask(3, 1000)
	)
	.traverse(of, f => f())
	.map(x=>x.toArray())
	.run()
	.promise()
})

if I change the following code, it gave me 1 2 3, which is what I expected.

List.prototype.traverse = function(point, f) {
	return this.reduce((ys, x) =>
		// f(x).map(x => y => y.concat([x])).ap(ys), point(this.empty))
		ys.map(x => y => x.concat([y])).ap(f(x)), point(this.empty))
}

Not sure it is a issue, or by design.

Typescript Support

It would be nice to be able to use this project with Typescript.
Is this something you would consider ?

Support for index of element in a list in .traverse method

Hello @DrBoolean,
I am a new-comer to FP and have watched all your videos to be able to start using it.
So currently we don't have access to index of element in List().traverse() method. Can you add it?

Basically, from
List([1,2]).traverse(Task.of, (ele) => Task.of(ele))
to
List([1,2]).traverse(Task.of, (ele, index) => Task.of(ele))

workaround for now (but it may not be ideal for each situation):
List([1,2]).toMap().traverse(Task.of, (ele, index) => Task.of(ele))
So index becomes the key if we use toMap()

Also, you can take a look at other methods to make sure we have access to the index, if possible.

I hope it is something that is easy for you to implement.

The argument roles in `concat` are not commutative?

Adding extra: false to the first concat argument generates type error, even when the same key is present on the second argument:

      Map({name: "brian", age: Sum(30), extra: false})
        .concat(
          Map({name: "lonsdorf", age: Sum(30), extra: true})
        ),
      Map({name: "brianlonsdorf", age: Sum(60), extra: true}))

generates

  1) Maps concats the vals:
     TypeError: prev.concat is not a function
      at mergeWith (index.js:53:46)
      at node_modules/immutable/dist/immutable.js:1956:52
      at updateInDeepMap (node_modules/immutable/dist/immutable.js:1973:22)
      at updateInDeepMap (node_modules/immutable/dist/immutable.js:1982:23)
      at Map.updateIn (node_modules/immutable/dist/immutable.js:1280:26)
      at Map.update (node_modules/immutable/dist/immutable.js:1272:14)
      at node_modules/immutable/dist/immutable.js:1955:22
      at node_modules/immutable/dist/immutable.js:1379:16
      at ArrayMapNode.iterate.HashCollisionNode.iterate [as iterate] (node_modules/immutable/dist/immutable.js:1728:11)
      at Map.__iterate (node_modules/immutable/dist/immutable.js:1377:32)
      at Map.forEach (node_modules/immutable/dist/immutable.js:4383:19)
      at node_modules/immutable/dist/immutable.js:1963:19
      at Map.withMutations (node_modules/immutable/dist/immutable.js:1355:7)
      at mergeIntoCollectionWith (node_modules/immutable/dist/immutable.js:1952:23)
      at mergeIntoMapWith (node_modules/immutable/dist/immutable.js:1925:12)
      at Map.mergeWith (node_modules/immutable/dist/immutable.js:1310:14)
      at Map.concat (index.js:53:15)
      at Context.it (test/test.js:24:10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.