Skip to content

Commit

Permalink
error on commas
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaly-t committed Jul 12, 2023
1 parent 8c5063f commit 7d5d329
Show file tree
Hide file tree
Showing 176 changed files with 890 additions and 889 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"/**/*.js"
],
"rules": {
"@typescript-eslint/comma-dangle": "off",
"@typescript-eslint/comma-dangle": "error",
"@typescript-eslint/quotes": ["error", "single"],
"@typescript-eslint/semi": ["error", "always"],
"@typescript-eslint/no-explicit-any": "off",
Expand Down
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"bracketSpacing": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"tabWidth": 4,
"overrides": [
{
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const input = [1, 2, 3, 4, 5];
const i = pipe(
input,
filter((a) => a % 2 === 0), // find even numbers
map((value) => ({value})), // remap into objects
map((value) => ({value})) // remap into objects
);

console.log(...i); //=> {value: 2}, {value: 4}
Expand All @@ -50,7 +50,7 @@ const input = [1, 2, 2, 3, 3, 4];
const i = pipe(
toAsync(input), // make asynchronous
distinct(), // emit unique numbers
delay(1000), // delay each value by 1s
delay(1000) // delay each value by 1s
);
// or you can replace `pipe` + `toAsync` with just `pipeAsync`

Expand Down
6 changes: 3 additions & 3 deletions benchmarks/src/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ const input: AsyncIterable<number> = {
return {
async next(): Promise<IteratorResult<number>> {
return i.next();
},
}
};
},
}
};

(async function testAsync() {
const result = {
...(await testIterOps(toAsync(data))),
...(await testRXJS(input)),
...(await testRXJS(input, true)),
...(await testRXJS(input, true))
};
console.log(`Asynchronous test for ${maxItems.toExponential()} items:`);
console.table(result);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ for (let i = 0; i < maxItems; i++) {
const result = {
...(await testIterOps(input)),
...(await testRXJS(input)),
...(await testRXJS(input, true)),
...(await testRXJS(input, true))
};
console.log(`Synchronous test for ${maxItems.toExponential()} items:`);
console.table(result);
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/tests/iter-ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function testIterOps(input: UnknownIterable<number>) {
input,
filter((a) => a % 2 === 0),
map((b) => ({value: b})),
toArray(),
toArray()
);
const {length} = (await i.first)!;
const duration = Date.now() - start;
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/tests/rxjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import {filter, firstValueFrom, from, map, toArray} from 'rxjs';

export async function testRXJS(
input: UnknownIterable<number>,
withSubscription?: boolean,
withSubscription?: boolean
) {
const start = Date.now();
const i = from(input).pipe(
filter((a) => a % 2 === 0),
map((b) => ({value: b})),
toArray(),
toArray()
);
if (withSubscription) {
// key to measuring RXJS correctly;
Expand Down
42 changes: 21 additions & 21 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const common = {
input: 'src/index.ts',

output: {
sourcemap: false,
sourcemap: false
},

external: [],
Expand All @@ -24,8 +24,8 @@ const common = {
annotations: true,
moduleSideEffects: [],
propertyReadSideEffects: false,
unknownGlobalSideEffects: false,
},
unknownGlobalSideEffects: false
}
};

/**
Expand All @@ -36,8 +36,8 @@ function getPlugins(tsconfig = 'tsconfig.build.json') {
rollupPluginAutoExternal(),
rollupPluginNodeResolve(),
rollupPluginTypescript({
tsconfig,
}),
tsconfig
})
];
}

Expand Down Expand Up @@ -75,10 +75,10 @@ const cjs = {
output: {
...common.output,
file: pkg.main,
format: 'cjs',
format: 'cjs'
},

plugins: getPlugins(),
plugins: getPlugins()
};

/**
Expand All @@ -90,10 +90,10 @@ const esm = {
output: {
...common.output,
file: pkg.module,
format: 'esm',
format: 'esm'
},

plugins: getPlugins(),
plugins: getPlugins()
};

/**
Expand All @@ -108,18 +108,18 @@ const web = {
file: 'dist/web/iter-ops.min.js',
format: 'iife',
name: 'iterOps',
banner: copyright,
banner: copyright
},

plugins: [
...getPlugins('tsconfig.build.web.json'),
rollupPluginTerser({
output: {
comments: 'some',
},
comments: 'some'
}
}),
rollupPluginGzip(),
],
rollupPluginGzip()
]
};

/**
Expand All @@ -131,18 +131,18 @@ const webModule = {
output: {
...web.output,
file: 'dist/web/iter-ops.min.mjs',
format: 'esm',
format: 'esm'
},

plugins: [
...getPlugins('tsconfig.build.web.json'),
rollupPluginTerser({
output: {
comments: 'some',
},
comments: 'some'
}
}),
rollupPluginGzip(),
],
rollupPluginGzip()
]
};

/**
Expand All @@ -153,10 +153,10 @@ const dts = {

output: {
file: pkg.types,
format: 'esm',
format: 'esm'
},

plugins: [rollupPluginDts()],
plugins: [rollupPluginDts()]
};

export default buildTypesOnly ? dts : [cjs, esm, web, webModule, dts];
30 changes: 15 additions & 15 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
isObject,
isPromiseLike,
isIndexed,
isArrayLike,
isArrayLike
} from './typeguards';
import {$A, $S, UnknownIterable} from './types';
import {indexedAsyncIterable} from './utils';
Expand Down Expand Up @@ -52,9 +52,9 @@ export function toAsync<T>(i: UnknownIterable<T>): AsyncIterable<T> {
return {
next(): Promise<IteratorResult<T>> {
return Promise.resolve(it.next());
},
}
};
},
}
};
}

Expand Down Expand Up @@ -179,9 +179,9 @@ export function toIterable<T>(i: unknown) {
}
started = true;
return value;
},
}
};
},
}
};
}
}
Expand All @@ -201,9 +201,9 @@ export function toIterable<T>(i: unknown) {
return k < i.length
? {value: i[k++] as T, done: false}
: {value: undefined, done: true};
},
}
};
},
}
};
}
}
Expand Down Expand Up @@ -233,7 +233,7 @@ export function toIterable<T>(i: unknown) {
export function reverse<T>(input: ArrayLike<T>): Iterable<T> {
if (typeof input?.length !== 'number') {
throw new TypeError(
`An array-like value was expected: ${JSON.stringify(input)}`,
`An array-like value was expected: ${JSON.stringify(input)}`
);
}
return {
Expand All @@ -244,9 +244,9 @@ export function reverse<T>(input: ArrayLike<T>): Iterable<T> {
return i
? {value: input[--i], done: false}
: {value: undefined, done: true};
},
}
};
},
}
};
}

Expand All @@ -261,7 +261,7 @@ function toSyncIterable<T>(value: T): Iterable<T> {
* Create an async iterable that has the awaited given value as its only element.
*/
function toSingleAsyncIterable<T>(
asyncValue: PromiseLike<T>,
asyncValue: PromiseLike<T>
): AsyncIterable<T> {
return {
[$A](): AsyncIterator<T> {
Expand All @@ -271,16 +271,16 @@ function toSingleAsyncIterable<T>(
if (finished) {
return Promise.resolve({
value: undefined,
done: true,
done: true
});
}
finished = true;
return (asyncValue as Promise<T>).then((value: T) => ({
value,
done: false,
done: false
}));
},
}
};
},
}
};
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export {
UnknownIterable,
UnknownIterableOrIterator,
UnknownIterator,
Value,
Value
} from './types';
export {reverse, toAsync, toIterable} from './helpers';
export {pipe, pipeSync, pipeAsync} from './pipe';
Expand Down Expand Up @@ -39,7 +39,7 @@ export {
onEnd,
IIterationSummary,
IDuration,
IValueDuration,
IValueDuration
} from './ops/on-end';
export {page} from './ops/page';
export {reduce} from './ops/reduce';
Expand Down
16 changes: 8 additions & 8 deletions src/ops/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {isPromiseLike} from '../typeguards';
* @category Sync+Async
*/
export function aggregate<T, R>(
cb: (arr: T[]) => R | Promise<R>,
cb: (arr: T[]) => R | Promise<R>
): Operation<T, R>;

export function aggregate(...args: unknown[]) {
Expand All @@ -41,7 +41,7 @@ export function aggregate(...args: unknown[]) {

function aggregateSync<T, R>(
iterable: Iterable<T>,
cb: (arr: T[]) => R,
cb: (arr: T[]) => R
): Iterable<R> {
return {
[$S](): Iterator<R> {
Expand All @@ -59,15 +59,15 @@ function aggregateSync<T, R>(
}
finished = true;
return {value: cb(arr), done: false};
},
}
};
},
}
};
}

function aggregateAsync<T, R>(
iterable: AsyncIterable<T>,
cb: (arr: T[]) => R | Promise<R>,
cb: (arr: T[]) => R | Promise<R>
): AsyncIterable<R> {
return {
[$A](): AsyncIterator<R> {
Expand All @@ -86,16 +86,16 @@ function aggregateAsync<T, R>(
if (isPromiseLike(r)) {
return r.then((value: R) => ({
value,
done: false,
done: false
}));
}
return {value: r, done: false};
}
arr.push(a.value);
return this.next();
});
},
}
};
},
}
};
}

0 comments on commit 7d5d329

Please sign in to comment.