Skip to content

Commit

Permalink
chore: edit formating
Browse files Browse the repository at this point in the history
  • Loading branch information
maraisr committed Jun 28, 2023
1 parent f230aeb commit de8ec89
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 89 deletions.
12 changes: 8 additions & 4 deletions .editorconfig
@@ -1,9 +1,13 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = tab
indent_size = 4
insert_final_newline = true
indent_style = tab
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{json,yml,yaml,md}]
indent_style = space
3 changes: 2 additions & 1 deletion bench/index.js
Expand Up @@ -11,7 +11,8 @@ const contenders = {
},
'dldr/cache': () => {
const cache = new Map();
return (keys) => Promise.all(keys.map((key) => dldrCache.load(loadFn, cache, key)));
return (keys) =>
Promise.all(keys.map((key) => dldrCache.load(loadFn, cache, key)));
},
dataloader: () => {
const loader = new DataLoader(loadFn, {
Expand Down
12 changes: 6 additions & 6 deletions bench/package.json
@@ -1,8 +1,8 @@
{
"type": "module",
"dependencies": {
"@marais/bench": "0.0.8",
"dataloader": "^2.2.2",
"dldr": "file:../"
}
"type": "module",
"dependencies": {
"@marais/bench": "0.0.8",
"dataloader": "^2.2.2",
"dldr": "file:../"
}
}
116 changes: 58 additions & 58 deletions package.json
@@ -1,60 +1,60 @@
{
"name": "dldr",
"version": "0.0.9",
"description": "A tiny (367B) utility for batching and caching operations",
"keywords": [
"dataloader",
"batch",
"graphql",
"utility"
],
"repository": "maraisr/dldr",
"license": "MIT",
"author": "Marais Rossow <me@marais.dev> (https://marais.io)",
"sideEffects": false,
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"require": "./index.js"
},
"./cache": {
"types": "./cache.d.ts",
"import": "./cache.mjs",
"require": "./cache.js"
},
"./package.json": "./package.json"
},
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"files": [
"*.d.ts",
"index.*",
"cache.*"
],
"scripts": {
"bench": "node bench/index.js",
"build": "bundt --minify",
"format": "prettier --write .",
"test": "uvu src \".test.ts$\" -r tsm",
"typecheck": "tsc --noEmit"
},
"prettier": "@marais/prettier",
"dependencies": {
"object-identity": "^0.1.1"
},
"devDependencies": {
"@marais/prettier": "0.0.2",
"@marais/tsconfig": "0.0.4",
"bundt": "2.0.0-next.5",
"nanospy": "1.0.0",
"prettier": "2.8.8",
"tsm": "2.3.0",
"typescript": "5.1.3",
"uvu": "0.5.4"
},
"volta": {
"node": "18.16.1"
}
"name": "dldr",
"version": "0.0.9",
"description": "A tiny (367B) utility for batching and caching operations",
"keywords": [
"dataloader",
"batch",
"graphql",
"utility"
],
"repository": "maraisr/dldr",
"license": "MIT",
"author": "Marais Rossow <me@marais.dev> (https://marais.io)",
"sideEffects": false,
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.mjs",
"require": "./index.js"
},
"./cache": {
"types": "./cache.d.ts",
"import": "./cache.mjs",
"require": "./cache.js"
},
"./package.json": "./package.json"
},
"main": "index.js",
"module": "index.mjs",
"types": "index.d.ts",
"files": [
"*.d.ts",
"index.*",
"cache.*"
],
"scripts": {
"bench": "node bench/index.js",
"build": "bundt --minify",
"format": "prettier --write .",
"test": "uvu src \".test.ts$\" -r tsm",
"typecheck": "tsc --noEmit"
},
"prettier": "@marais/prettier",
"dependencies": {
"object-identity": "^0.1.1"
},
"devDependencies": {
"@marais/prettier": "0.0.4",
"@marais/tsconfig": "0.0.4",
"bundt": "2.0.0-next.5",
"nanospy": "1.0.0",
"prettier": "2.8.8",
"tsm": "2.3.0",
"typescript": "5.1.3",
"uvu": "0.5.4"
},
"volta": {
"node": "18.16.1"
}
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/index.test.ts
Expand Up @@ -107,7 +107,10 @@ test('new batch once await', async () => {
assert.equal(items[1], 'b');
assert.equal(items[2], 'c');

const items2 = await Promise.all([dldr.load(loader, 'd'), dldr.load(loader, 'e')]);
const items2 = await Promise.all([
dldr.load(loader, 'd'),
dldr.load(loader, 'e'),
]);

assert.equal(loader.callCount, 2);
assert.equal(loader.calls[1], [['d', 'e']]);
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Expand Up @@ -37,7 +37,9 @@ export function load<T, K = string>(
for (
;
(tmp = values[i++]), i <= values.length;
tmp instanceof Error ? tasks[i - 1].r(tmp) : tasks[i - 1].s(tmp)
tmp instanceof Error
? tasks[i - 1].r(tmp)
: tasks[i - 1].s(tmp)
);
}, reject);

Expand Down
12 changes: 8 additions & 4 deletions src/index.types.ts
Expand Up @@ -28,7 +28,11 @@ assert<Promise<User>>(dldr.load(loadFn<{ id: string }, User>, { id: '123' }));
// @ts-expect-error
assert<Promise<User>>(dldr.load(loadFn<{ id: string }, User>, { id: 123 }));

assert<Promise<User>>(dldr.load(loadFn<{ id: string }, User>, { id: '123' }, '123'));

// @ts-expect-error
assert<Promise<User>>(dldr.load(loadFn<{ id: string }, User>, { id: '123' }, 123));
assert<Promise<User>>(
dldr.load(loadFn<{ id: string }, User>, { id: '123' }, '123'),
);

assert<Promise<User>>(
// @ts-expect-error
dldr.load(loadFn<{ id: string }, User>, { id: '123' }, 123),
);
20 changes: 10 additions & 10 deletions tsconfig.json
@@ -1,12 +1,12 @@
{
"extends": "@marais/tsconfig",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"dldr": ["src/index.d.ts"],
"dldr/*": ["src/*.d.ts"]
}
},
"include": ["src", "test"],
"exclude": ["node_modules"]
"extends": "@marais/tsconfig",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"dldr": ["src/index.d.ts"],
"dldr/*": ["src/*.d.ts"]
}
},
"include": ["src", "test"],
"exclude": ["node_modules"]
}

0 comments on commit de8ec89

Please sign in to comment.