hg-pyun / iterize Goto Github PK
View Code? Open in Web Editor NEWUse JavaScript Iterator, Easily
License: MIT License
Use JavaScript Iterator, Easily
License: MIT License
Change Word
generator -> Iterable protocol
Add Import Guide
import * as iterize from 'iterize';
or
import { range } from 'iterize';
// As - Is
import { range } from 'iterize';
// To - Be
import {range} from 'iterize';
// As - Is
iterize.range
// To - Be
range
Define Argument Types.
Reference: https://github.com/line/line-bot-sdk-nodejs/blob/master/lib/types.ts
When the prettier setting is done, reformatting the all codes.
Is it necessary dividing take and takewhile ?
range(1, 10) // default step 1,
range(10, 1) // default step -1
take(x => x < 5, [1,4,6,4,1]) --> 1 4
Make change log for versions on markdown document.
Improve range API.
range(5) // [0, 1, 2, 3, 4]
range(1, 10) // default step 1,
range(10, 1) // default step -1
Set up Prettier
A test code is required for the spread operator.
Here are some example.
[...range(1, 10, 1)]; // [1, 2, 3 ... 9]
[...range(1, 10, x => x + 1)]; // [1, 2, 3 ... 9]
[...range(2, 64, x => x * x)]; // [2, 4, 16]
const rangeIterator = range(1, 5, 1);
[...replicate(2, rangeIterator)]; // [1, 2, 3, 4, 1, 2, 3, 4]
cycle('ABCD') --> A B C D A B C D ...
Add Issue and Pull Request Templates.
Here are some reference
Merge repeat and replicate api. Because of duplicated method.
repeat(item, count);
Setup document guide page.
i think it used to github.io
.
@ts-ignore
change to <any>
type casting on test cases
cycle, repeat, replicate
check the iterator param that RepeatIterator
.
It is not necessary to include repetition in a function that is already repetitive.
RepeatIterator
.Many libraries support logging message for easy debugging. Normally, using process.env.NODE_ENV
, switching between dev and production environment. Let's talking about this.
#1 Development is done.
Let's discussion combination APIs.
let range = iterize.range(1, 5, 1);
cycle(range);
// 1 2 3 4 1 2 3 4 1 2 3 4 ...
generator
type parameterconst range = iterize.range(1, 5, 1);
iterlize.replicate(2, range);
1 2 3 4 1 2 3 4
Iterize needs to benchmarks for testing native or another library.
cycle('ABCD') --> A B C D A B C D ...
repeat(item, count);
takewhile(x => x < 5, [1,4,6,4,1]) --> 1 4
accumulate([1,2,3,4,5]) --> 1 3 6 10 15
accumulate([1,2,3,4,5], operator.mul) --> 1 2 6 24 120
Current test cases are written inefficiently.
{ value: 0, done: false }
// refactor using 'for' syntax
it('number type', () => {
const iter = repeat(0);
expect(iter.next()).to.deep.equal({ value: 0, done: false });
expect(iter.next()).to.deep.equal({ value: 0, done: false });
expect(iter.next()).to.deep.equal({ value: 0, done: false });
expect(iter.next()).to.deep.equal({ value: 0, done: false });
expect(iter.next()).to.deep.equal({ value: 0, done: false });
});
for
syntaxDiscuss 1.3.0 features.
Happy New Year 🎉
Release 1.1.0
Currently, it is built in a structure that can only be used in nodejs using the babel-runtime. For immediate use by browser via CDN, source code bundling is required. Now we're thinking about using webpack to create a version that we build separately.
Purchase iterize.io domain
Need to write down for-of test code.
How about add for-of syntax example on README.md or cookbook ?
The parts that receive the Iterator in the replicate and cycle APIs are not exactly satisfied with the lazy evaluation. This is because an array is built internally using the spread operator.
if (isGenerator) {
cycleItem = [...item];
}
if (isGenerator(item)) {
let spreadItem = [...(item as IterableIterator<any>)];
let iterItem: any[] = [];
for (let i = 0; i < count; i++) {
iterItem = iterItem.concat(spreadItem);
}
...
Improvements are needed to evaluate dynamically using iterator.
Support UMD by https://github.com/umdjs/umd
How about this ?
if(someObject(Symbol.iterator]))
Update Contributing Guide
Discuss bring in CI Tools
Support Function Type.
cycle([fn1, fn2, fn3])
repeat(fn);
replicate(3, fn);
fn
argumentDescription about API architecture.
// API
range(start: number, end: number, step: number | Function): Iterator
// example
iterize.range(1, 10, 1);
iterize.range(1, 10, x => x+1);
1 2 3 ... 9
// API
cycle(arr: Array<any>): Iterator
// example
iterize.cycle([1, 2, 3]);
1 2 3 1 2 3 1 2 3 1 2 ...
// API
iterize.take(count: number, iter: Iterator): Iterator
// example
const cycle = lterize.cycle([1, 2, 3]);
iterize.take(5, cycle);
[1, 2, 3, 1, 2]
// API
iterize.repeat(item: number | string): Iterator
// example
iterize.repeat(5)
5 5 5 5 5 5 5 5 ...
// API
iterize.replicate(count: number, item: number | string): Iterator
// example
iterize.replicate(3, 10)
10 10 10
Many library have cookbook that explain how to use it. It seems that it could make many combinations.
How about write cookbook? I attach reference ramda.
How about add promise argument ?
take(a => a <2, [Promise.resolve(1), Promise.resolve(2)]);
Improve Prettier Rules
Write down API Document. For now, write down the definition of api spec on README.md
.
After Let's make a later API-related document.
Change License Apache 2.0 to MIT
Define *.d.ts, TBD
Add PR Templates.
There is currently overlap in the error model. It optimizes this.
Redesign Error Model.
Currently, Mocha is testing all of the test cases. We need to create a partially testable environment.
TBD
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.