Skip to content

Commit 2483acb

Browse files
feat: add Rollup configuration for ESM build
- Created rollup.config.js to bundle the ESM version of the library. - Set up TypeScript plugin with appropriate options for source maps and comment removal. fix: ensure non-null assertions in Memoized class - Updated tryGet and iterator methods to use non-null assertions for cached values. test: add comprehensive tests for Memoized functionality - Implemented tests to verify caching behavior, iterator functionality, and random access in Memoized class. chore: update TypeScript configuration files - Modified tsconfig.cjs.json and tsconfig.esm.json to enable emitting output and source maps. - Refined tsconfig.json to improve strictness and remove unnecessary options. - Updated tsconfig.types.json to specify output directory for type declarations. - Removed tsconfig.umd.json as it is no longer needed.
1 parent 7bb787b commit 2483acb

19 files changed

+901
-728
lines changed

.build/validate-package.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

dist/Memoized.d.ts

Lines changed: 0 additions & 54 deletions
This file was deleted.

dist/cjs/Memoized.js

Lines changed: 1 addition & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cjs/Memoized.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/Memoized.js

Lines changed: 6 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/Memoized.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/types/Memoized.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*!
2+
* @author electricessence / https://github.com/electricessence/
3+
* Licensing: MIT
4+
*/
5+
export declare class Memoized<T> implements Iterable<T>, Iterator<T> {
6+
private _iterator;
7+
private readonly _cached;
8+
constructor(source: Iterable<T>);
9+
hasCached(index: number): boolean;
10+
ensure(index: number): boolean;
11+
get(index: number): T | undefined;
12+
tryGet(index: number, out: (e: T) => void): boolean;
13+
[Symbol.iterator](): Iterator<T>;
14+
next(): IteratorResult<T>;
15+
}
16+
export default function memoize<T>(source: Iterable<T>): Memoized<T>;

0 commit comments

Comments
 (0)