Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

batchloader

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batchloader - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

lib/cacheloader.d.ts

2

lib/batchloader.d.ts

@@ -0,1 +1,2 @@

import { Cache, CacheLoader } from './cacheloader';
import { MappedBatchLoader } from './mappedbatchloader';

@@ -16,2 +17,3 @@ import { IBatchLoader } from './types';

mapLoader<MappedValue>(mapFn: (value: Value) => MappedValue): MappedBatchLoader<Key, Value, MappedValue>;
cacheLoader(cache?: Cache<Key, Value>): CacheLoader<Key, Value>;
protected triggerBatch(): Promise<Value[]>;

@@ -18,0 +20,0 @@ protected runBatchNow(): Promise<Value[]>;

7

lib/batchloader.js

@@ -11,2 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const cacheloader_1 = require("./cacheloader");
const mappedbatchloader_1 = require("./mappedbatchloader");

@@ -44,2 +45,5 @@ const sleep = (ms) => new Promise((resolve) => {

}
cacheLoader(cache) {
return new cacheloader_1.CacheLoader(this, cache);
}
triggerBatch() {

@@ -57,5 +61,2 @@ return (this.batchPromise ||

const { queuedKeys, keyToUniqueId } = this;
if (!queuedKeys.length) {
return [];
}
this.queuedKeys = [];

@@ -62,0 +63,0 @@ if (keyToUniqueId) {

{
"name": "batchloader",
"version": "0.0.6",
"version": "0.0.7",
"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",

@@ -22,2 +22,3 @@ import { BatchLoader } from './batchloader';

expect(await loader.loadMany([])).toEqual([]);
expect(await loader.loadMany([])).toEqual([]);
expect(await loader.loadMany([1, 2, 3])).toEqual([2, 4, 6]);

@@ -33,2 +34,3 @@ expect(await loader.loadMany([1, 2, 3, 2, 3, 2, 1])).toEqual([

]);
expect(await loader.loadMany([])).toEqual([]);

@@ -35,0 +37,0 @@ expect(

@@ -0,1 +1,2 @@

import { Cache, CacheLoader } from 'src/cacheloader';
import { MappedBatchLoader } from 'src/mappedbatchloader';

@@ -56,2 +57,6 @@ import { IBatchLoader, MaybePromise } from 'src/types';

public cacheLoader(cache?: Cache<Key, Value>): CacheLoader<Key, Value> {
return new CacheLoader(this, cache);
}
protected triggerBatch(): Promise<Value[]> {

@@ -73,6 +78,2 @@ return (

const { queuedKeys, keyToUniqueId } = this;
if (!queuedKeys.length) {
return [];
}
this.queuedKeys = [];

@@ -79,0 +80,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc