batchloader
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -8,3 +8,4 @@ import { IBatchLoader } from './types'; | ||
loadMany(keys: Key[]): Promise<MappedValue[]>; | ||
mapLoader<RemappedValue>(mapFn: (value: MappedValue) => RemappedValue): MappedBatchLoader<Key, MappedValue, RemappedValue>; | ||
private mapItems; | ||
} |
@@ -25,4 +25,7 @@ "use strict"; | ||
} | ||
mapLoader(mapFn) { | ||
return new MappedBatchLoader(this, mapFn); | ||
} | ||
} | ||
exports.MappedBatchLoader = MappedBatchLoader; | ||
//# sourceMappingURL=mappedbatchloader.js.map |
export interface IBatchLoader<Key, Value> { | ||
load(key: Key): Promise<Value>; | ||
loadMany(keys: Key[]): Promise<Value[]>; | ||
mapLoader<MappedValue>(mapFn: (value: Value) => MappedValue): IBatchLoader<Key, MappedValue>; | ||
} |
{ | ||
"name": "batchloader", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "BatchLoader is a utility for data fetching layer to reduce requests via batching written in TypeScript. Inspired by Facebook's DataLoader", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -19,2 +19,8 @@ import { IBatchLoader } from 'src/types'; | ||
public mapLoader<RemappedValue>( | ||
mapFn: (value: MappedValue) => RemappedValue | ||
): MappedBatchLoader<Key, MappedValue, RemappedValue> { | ||
return new MappedBatchLoader(this, mapFn); | ||
} | ||
private mapItems = (vs: Value[]): MappedValue[] | Promise<MappedValue[]> => { | ||
@@ -21,0 +27,0 @@ const mapped = vs.map(this.mapFn); |
export interface IBatchLoader<Key, Value> { | ||
load(key: Key): Promise<Value>; | ||
loadMany(keys: Key[]): Promise<Value[]>; | ||
mapLoader<MappedValue>( | ||
mapFn: (value: Value) => MappedValue | ||
): IBatchLoader<Key, MappedValue>; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28891
497