Giter VIP home page Giter VIP logo

ixjs's People

Contributors

0xflotus avatar aikoven avatar alexaegis avatar antoinepairet avatar david-driscoll avatar deebloo avatar dependabot[bot] avatar desnor avatar dgadelha avatar dobesv avatar eikooc avatar forivall avatar greenkeeper[bot] avatar justsml avatar konanmentor avatar kwonoj avatar lizardruss avatar mattpodwysocki avatar micahstubbs avatar michaelsbradleyjr avatar mpodwysocki avatar mxstbr avatar nordfjord avatar patsissons avatar tetsuharuohzeki avatar timoxley avatar trxcllnt avatar wonism 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  avatar  avatar

ixjs's Issues

Reimplement operators by new design

After merging #16, almost operators implementations are disabled (commented out) for enable TravisCI once.

Their disabled codes has not been moved to the current design introduced by #11 yet. Thus we need to reimplement them by the new design.

BTW, I feel Ix's basic operator design has not been fixed. We also need to consider it.

Use iterall

How about using iterall by Lee Byron to replace some stuff in IxJS/src/internal?

flatMap operator has no resultSelector parameter

IxJS version: 2.0.1

Additional information:

flatMap will always emit the inner result, which is sometimes not desired. we can use an optional resultSelector parameter to inject our own result projection using both the inner and outer values.

Enable TravisCI

Before merging any pull request, we should check the build result.

Add Prepend and Append as standard methods

IxJS version: 2.x

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

Add prepend and append to IxJS for both AsyncIterableX and IterableX to support n-ary arguments as they are standard .NET LINQ methods.

postinstall script using shelljs doesn't escape $

IxJS version:
2.3.2

Code to reproduce:
npm install ix in windows

Expected behavior:
ix is installed

Actual behavior:

> [email protected] postinstall C:\...\node_modules\ix
> npm i shx && npm run tslib_mjs && npm run tslib_pkg && npm r shx

> [email protected] tslib_mjs C:\...\node_modules\ix
> shx cp $(node -e "console.log(require.resolve('tslib/tslib.es6.js'))") $(node -e "var r=require,p=r('path');console.log(p.join(p.dirname(r.resolve('tslib')),'tslib.mjs'))")

$(node was unexpected at this time.

C:\...\node_modules\ix>  "C:\...\node_modules\ix\node_modules\.bin\\node.exe"  "C:\...\node_modules\ix\node_modules\.bin\\..\shx\lib\cli.js" cp $(node -e "console.log(require.resolve('tslib/tslib.es6.js'))") $(node -e "var r=require,p=r('path');console.log(p.join(p.dirname(r.resolve('tslib')),'tslib.mjs'))")

npm ERR! Windows_NT 10.0.16299
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "tslib_mjs"
npm ERR! node v6.11.4
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] tslib_mjs: `shx cp $(node -e "console.log(require.resolve('tslib/tslib.es6.js'))") $(node -e "var r=require,p=r('path');console.log(p.join(p.dirname(r.resolve('tslib')),'tslib.mjs'))")`
npm ERR! Exit status 255
npm ERR!
npm ERR! Failed at the [email protected] tslib_mjs script 'shx cp $(node -e "console.log(require.resolve('tslib/tslib.es6.js'))") $(node -e "var r=require,p=r('path');console.log(p.join(p.dirname(r.resolve('tslib')),'tslib.mjs'))")'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the ix package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     shx cp $(node -e "console.log(require.resolve('tslib/tslib.es6.js'))") $(node -e "var r=require,p=r('path');console.log(p.join(p.dirname(r.resolve('tslib')),'tslib.mjs'))")

Additional information:
Related commit: 4493754

I'm guessing this is due to $(node being interpreted literally rather than as an embedded expression.

Operator: flatten

Hi!

Are you planning to add a flatten operator for sync and async iterables?

Thanks,
Oliver

Implement from Node.js Streams

IxJS version:

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

IxJS, since it's specialty is in I/O problems, that we need explicit conversions to and from Node.js streams. This will intrinsically support backpressure as you do not pull more than you need. We already have AsyncSink which is a Node.js stream already, but we would like a more explicit approach.

export function fromReadableStream(
  stream: Readable, 
  size?: number)
: AsyncIterable<string | Buffer>;

from(Observable) does not handle asynchronously emitting observables

IxJS version:
v2.3.1

Code to reproduce:

import * as Ix from 'ix';
import { Observable } from 'rxjs';
import 'rxjs/add/observable/interval';

Ix.AsyncIterable.from(Observable.interval(100))
  .forEach(x => console.log(`Next ${x}`));

Expected behavior:
It should iterate the values from the observable.

Actual behavior:
No values are iterated.

Additional information:
PR #150 submitted to address this issue.

Cancellation?

Do you have any ideas for how an async iterable, transformed using IxJS, can be cancelled by the consumer?

Obviously, async iterables use Promises which are not cancellable.

I'm really starting to wish async iterables used something that did support cancellation, such as Tasks. Then the user could receive an unsubscribe function, just like in RxJS with the Observable type.

An in-range update of tslib is breaking the build 🚨

Version 1.9.0 of tslib was just published.

Branch Build failing 🚨
Dependency tslib
Current Version 1.8.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

tslib is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Release Notes tslib 1.9.0

This release introduces import helpers that are utilized by TypeScript 2.7's --esModuleInterop flag for interoperability between ECMAScript modules and legacy module formats.

Commits

The new version differs by 4 commits.

  • 3d0f4d4 Update version to '1.9.0'.
  • c380b8d Merge pull request #43 from Microsoft/import-helpers
  • c1cd8e1 Remove erroneous semicolons from import star helper
  • b630cee Add import helpers

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

default comparer function should be more accurate

IxJS version:
2.1.4

Code to reproduce:

import { Iterable } from 'ix';

// actually false (count is 1)
const shouldBeTrue = Iterable.of('foo', 'bar').distinct().count() === 2;

Expected behavior:
shouldBeTrue should be true

Actual behavior:
shouldBeTrue is be false

Additional information:
the default comparer should have some more comparator fallbacks to better handle strings and objects. I have been using a custom comparer for a while now, it may be a bit overkill but it works really well with whatever you throw at it.

export interface Comparable<T> {
  compareTo(other: T): number;
}

export function isComparable<T>(obj: any): obj is Comparable<T> {
  return (<Comparable<T>>obj).compareTo instanceof Function;
}

export function isString(value: any): value is string {
  return typeof(value) === 'string' || value instanceof String;
}

export function DefaultComparer(a: any, b: any) {
  if (a === b || (a == null && b == null)) {
    // both are null or the same, so equality is zero
    return 0;
  }
  else if (a == null || b == null) {
    // only one is null, non-null takes higher value
    return a == null ? -1 : 1;
  }
  else if (typeof a === 'object' || typeof b === 'object') {
    // if either side is an object then we have failed referencial equality (first compare)
    return -1;
  }
  else if (isComparable(a)) {
    // implements Comparable
    return a.compareTo(b);
  }
  else if (String.isString(a) && String.isString(b)) {
    // native string comparison
    return a.localeCompare(b);
  }
  else {
    // fallback on a basic equality check
    const c: number | undefined = a - b;

    // it's possible that our basic check failed, so default to zero
    return (c == null || isNaN(c)) ? 0 : c;
  }
}

EDIT: forgot to include the object comparer.

groupBy operator has no resultSelector parameter

IxJS version: 2.0.1

Additional information:

groupBy will always emit GroupedIterable or GroupedAsyncIterable instances are results, which are sometimes not desired. we can use an optional resultSelector parameter to inject our own result projection into the operator.

Create a Gitter channel

Would be great to have one, the RxJS Gitter channel is one of the best and most active I know

chain example in docs: of, map, filter is not a function (with CommonJS require)

It looks like in the chain example we import the object that has a method we want. I think the idea of the example is to assign the map method itself to a variable, rather than assigning it's parent object.

IxJS version:
"ix": "^2.1.4"

Code to reproduce:

// CommonJS
const Iterable = require('ix/iterable').IterableX;
require('ix/add/iterable-operators/chain');
const of = require('ix/iterable/of');
const filter = require('ix/iterable/filter');
const map = require('ix/iterable/map');

const results = of(1, 2, 3)
  .chain(source => filter(source, x => x % 2 === 0))
  .chain(source => map(source, x => x * x));

for (let item of results) {
  console.log(`Next: ${item}`);
}

Expected behavior:
output Next 4

Actual behavior:
error message

Add Prettier support

IxJS version: 2.x

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

Add prettier support for nicer code formatting.

Asynciterable forEachAsync recurse function should return promise?

Hey there,

Just looking through the code and noticed the following entry inside asynciterable.js:

  var recurse = function () {
    p = e.next().then(function (result) {
      if (!result.done) {
        cb(result.value, i++);
        recurse();
      } else {
        Promise.resolve();
      }
    });
   return p;
  };

Should this instead be?:

  var recurse = function () {
    p = e.next().then(function (result) {
      if (!result.done) {
        cb(result.value, i++);
        return recurse();
      } else {
        return Promise.resolve();
      }
    });
    return p;
  };

I.e.: Shouldn't the function return a promise? This ensures the promise doesn't resolve on the first element.

Pipe-able orderBy

IxJS version: 2.3.4

Code to reproduce:

import { IterableX as Iterable } from 'ix/iterable'
import { orderBy } from 'ix/iterable/pipe'

const example = Iterable.of({a: 1}, {a: 3}, {a: 2})
    .pipe(orderBy(item => item.a))

Expected behavior:

An imported pipe-able orderBy.

Actual behavior:

There is no orderBy under src/iterable/pipe, so it cannot be imported or used.

Additional information:

This appears to be a simple oversight / missed operator file in the pipe PR.

Narrowed types from user defined type guards are lost in subsequent method calls

IxJS version: 2.3.1

Code to reproduce:

// no error, good!
const xs2: Ix.Iterable<number> = Ix.Iterable
    .from(['foo', 1])
    .filter((x): x is number => typeof x === 'number')

// no error, good!
const xs2b: Ix.Iterable<number> = xs2.map(x => x);

// unexpected error, bad!
const xs3: Ix.Iterable<number> = Ix.Iterable
    .from(['foo', 1])
    .filter((x): x is number => typeof x === 'number')
    .map(x => x)

Related #44

Operator: takeUntil

Hi!

Are there plans to add a takeUntil operator to this library?

If so, I was wondering if we would have inclusive (take until and including) and exclusive versions (take until and excluding the first falsy predicate).

Support user defined type guards in filter predicates

IxJS version:
2.1.0

Code to reproduce:

// no error, good!
// TypeScript's Array typings support user defined type guards in the filter predicate
const xs: number[] = ['foo', 1].filter((x): x is number => x instanceof Number);

// unexpected error
const xs2: Ix.Iterable<number> = Ix.Iterable
    .from(['foo', 1])
    .filter((x): x is number => typeof x === 'number');

Lettable operator examples are wrong

IxJS version: 2.3.4

Code to reproduce:

The README has the following example on how to use lettable operators:

import { IterableX as Iterable } from 'ix/iterable';
import { map, filter } from 'ix/iterable/pipe';

// CommonJS
const Iterable = require('ix/iterable').IterableX;
const { map, filter } = require('ix/iterable/pipe');

const results = of(1, 2, 3).pipe(
  filter(x => x % 2 === 0),
  map(x => x * x)
);

for (let item of results) {
  console.log(`Next: ${item}`);
}

A few issues here:

  • Where does of come from?
  • import { map, filter } from 'ix/iterable/pipe'; does not seem to work. Rather one has to do import { map } from 'ix/iterable/pipe/map'; etc.

Modules Not Found in Angular CLI Application

Within an Angular/CLI application (in VS Code), ES imports cannot resolve the modules. For example, these imports fail...

import { IterableX as Iterable } from 'ix/iterable';
import 'ix/add/iterable/of';
import 'ix/add/iterable-operators/map';
import { map } from 'ix/iterable/map';
import { filter } from 'ix/iterable/filter';

However, this import does work...

import * as Ix from 'ix';

That, sadly, does not give me access to 'ix/iterable' functions.

Curried and args switched

Would be nice to have some methods curried (and because of that switched arguments) to align with FP style.

Example:

// Current
const results = of(1, 2, 3)
  .chain(source => filter(source, x => x % 2 === 0))
  .chain(source => map(source, x => x * x));

// Possible with args switched (and curried)
const results = of(1, 2, 3)
  .chain(filter(x => x % 2 === 0))
  .chain(map(x => x * x));

v2.1.2 will be compile error with TypeScript 2.5.3

IxJS version

Code to reproduce

tsc -p ./tsconfig.json

tsconfig.json

{
  "compilerOptions": {
    /* Basic Options */
    "target": "esnext",
    "module": "esnext",
    "lib": [
      "es2017",
      "dom",
      "esnext.asynciterable"
    ],

    /* Strict Type-Checking Options */
    "strict": true,
    /* Additional Checks */
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,

    /* Module Resolution Options */
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": false
  },

  "include": [
    "./src/**/*",
  ],

  "exclude": [
    "node_modules"
  ]
}

example.ts

import Ix from 'ix';
Ix.Iterable.from([1, 2]).forEach(console.log);

Expected behavior:

Threre are no error.

Actual behavior:

tsc causes these error:

node_modules/ix/add/asynciterable-operators/flatmap.ts(10,5): error TS6133: 'thisArg' is declared but never used.
node_modules/ix/add/iterable-operators/flatmap.ts(10,5): error TS6133: 'thisArg' is declared but never used.
node_modules/ix/add/iterable-operators/scan.ts(18,3): error TS2322: Type 'IterableX<T | R | undefined>' is not assignable to type 'IterableX<T | R>'.
  Type 'T | R | undefined' is not assignable to type 'T | R'.
    Type 'undefined' is not assignable to type 'T | R'.
node_modules/ix/asynciterable/from.ts(122,36): error TS2345: Argument of type 'TSource | undefined' is not assignable to parameter of type 'TSource'.
  Type 'undefined' is not assignable to type 'TSource'.

Additional information:

  • If I use @reactivex/ix-esnext-esm, then there are no error.

An in-range update of tslib is breaking the build 🚨

Version 1.8.0 of tslib was just published.

Branch Build failing 🚨
Dependency tslib
Current Version 1.7.1
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

tslib is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build is in progress Details
  • ❌ continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 13 commits.

  • b780e46 Update version number.
  • 763381d Merge pull request #39 from Microsoft/makeTemplateObject
  • 711ef41 Merge branch 'master' into makeTemplateObject
  • 664aef7 Merge pull request #40 from lolipop99/patch-1
  • 0993808 Use consistent quotes style on throw.
  • ce64e76 Updated '__makeTemplateObject'.
  • 8571ea7 Update tslib.es6.js
  • f3c874d Add the '__makeTemplateObject' helper.
  • 2169db3 Merge pull request #38 from Microsoft/exampleOutput
  • ba7f283 Made the README a little more explicit about why the package is useful.
  • 4ae2cad set the __esModule marker in createExporter (#28)
  • b41a03b Merge pull request #35 from aluanhaddad/patch-1
  • f4578a0 update jspm instructions

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Test harness

@mattpodwysocki There currently isn't any testing harness. Can we add one? I have no preferences on which one, although it should support promises.

Next release

Hi there,

I noticed there are some big changes in master pending a release. When can we expect a release?

Thanks!

Deprecate startWith in favor of prepend

IxJS version: 2.x

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

Deprecate the usage of startWith in favor of prepend which will align with Ix .NET and Rx .NET

Implement combineLatest for AsyncIterable

IxJS version:

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

Add combineLatest which mirrors zip but will track the latest from each AsyncIterable input.

function delay(time) {
  return new Promise(res => setTimeout(res, time));
}

async function* delayEvery(value, time) {
  while (1) {
    await delay(time);
    yield value;
  }
}

const s1 = delayEvery(42, 500);
const s2 = delayEvery(56, 1250);

const s3 = combineLatest(s1, s2);
for await (const [fst, snd] of s3) {
  console.log(`{fst} - {snd}`);
}

transpile gulpfile?

curious, would it make sense to transpile the gulpfile down to ES5? when I run gulp build, it complains about the ... spread operator

screen shot 2017-10-07 at 9 33 40 pm

screen shot 2017-10-07 at 9 39 22 pm

Update docs to include some getting started details with tsconfig

IxJS version: 2.0.1

Additional information:

When i got started with ix while targetting es5 I did not realize that I would need to add some extra libs to the typescript compiler to get things compiling (I had thought I was missing some @types for shims). by adding esnext.asynciterable to lib I was able to bring in the necessary type definitions to squelch the compiler errors. While it didn't take me too long to figure this out, anyone not very familiar with the typescript compilation process might struggle with this. You could also maybe point them to your own source controlled tsconfig.base.json, but i think the only absolutely required lib is esnext.asynciterable (which itself brings in symbol and iterable).

No ordered iterable type is exported

IxJS version: 2.0.1

Code to reproduce: let source: OrderedIterable<number> = Iterable.from([1]).orderBy(x => x)

Expected behavior: No type definition errors on OrderedIterable

Actual behavior: no exported member OrderedIterable<T>

Additional information:

This is useful if we ever need to define an unassigned ordered iterable variable. It's also convenient if we want to re-assign a variable via dynamic chaining (i.e. orderby, if condition thenby).

This ought to be a relatively simple fix. The simple version is to simply export OrderedIterableBaseX as OrderedIterable in the api surface. A slightly more involved fix is to create an actual OrderedIterable interface and export that (though i doubt it provides any benefits over the simple fix).

Document package usage better

I've had trouble using the package with a webpack-based build, the reason being that the types are not colocated with the .js files. Here's the line in tsconfig.json that finally made it work:

"paths" : {
            "ix/*": [ "./node_modules/ix/targets/es5/cjs/*", "./node_modules/ix/types/*" ]
        }

How about documenting this better, and even considering shipping with a package that is more "traditional" in structure and works out of the box - similar to the one for rxjs for instance - this would probably ease adoption.

Full re-write... Happy to contribute

Hi guys,

I have just committed a full re-write of IxJS in TypeScript, complete with several new operators and tests. I followed the RxJS pattern of things (including extending base types, and npm scripts).

Please see here: https://github.com/christyharagan/IxJS

I haven't published any packages yet as I'd like to make the offer of migrating re-write code to this repository.

It works for CJS, AMD, and ES6, has full test coverage (although I'm sure the tests themselves may need beefing up), and linting.

Let me know what you guys think.

I'd also like to propose the generator* extensions for async-iterators to the TypeScript guys, although if the base spec is likely to change a lot, then I'll hold off.

Let me know what you think...

orderby operators missing from api surface

IxJS version: 2.0.1

Code to reproduce: Iterable.from([1]).orderBy(x => x)

Expected behavior: returns an ordered iterable

Actual behavior: property 'orderBy' does not exist on type 'Iterable<T>'

Additional information:

The operator add import is just missing from the api surface, not sure if that was intentional or not.

some operator should support omitted comparer

IxJS version: 2.0.1

Code to reproduce: Iterable.of([1]).some()

Expected behavior: returns true

Actual behavior: expected 1 params, but got 0

Additional information:

pretty simple fix, just change
if (comparer(item, i++)) { return true; }
to
if (!comparer || comparer(item, i++)) { return true; }

Rethink skipUntil and takeUntil

IxJS version: 2.x

Code to reproduce:

Expected behavior:

Actual behavior:

Additional information:

Current implementations of takeUntil and skipUntil accept Promise values as parameters which is problematic given their eager nature. Instead, we should look into the following overloads which support AsyncIterator as well as () => Promise<any>.

export function skipUntil<T>(
  source: AsyncIterable<T>, 
  other: () => Promise<any>);

export function skipUntil<T>(
  source: AsyncIterable<T>,
  other: AsyncIterable<any>);

export function takeUntil<T>(
  source: AsyncIterable<T>, 
  other: () => Promise<any>);

export function takeUntil<T>(
  source: AsyncIterable<T>,
  other: AsyncIterable<any>);

Typescript distribution

IxJS version: 2.0.1

Under the new publishing regime with its breakdown by target and module type, and since I am already using Typescript myself, I would like to see a @reactivex/ix-ts that is simply a package of the Typescript source files without cruft and loadable directly as is. This would allow me to use my project's existing tsconfig.json target and module settings. This would make it easier to be more nimble in my own builds/packs, for example. It also further reduces the possibility space where TS may be able to load the types for the library, but not, for example, webpack find the JS modules and/or vice versa.

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.