Skip to content

Commit

Permalink
add /async.ts#is_promise
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanatkn committed Mar 6, 2024
1 parent de590d3 commit a5d3bb6
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .changeset/spicy-schools-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ryanatkn/belt": patch
---

add `$lib/async.ts#is_promise`
122 changes: 61 additions & 61 deletions package-lock.json

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

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,22 @@
"devDependencies": {
"@changesets/changelog-git": "^0.2.0",
"@ryanatkn/eslint-config": "^0.1.0",
"@ryanatkn/fuz": "^0.91.0",
"@ryanatkn/fuz": "^0.91.3",
"@ryanatkn/gro": "^0.112.4",
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.5.2",
"@sveltejs/package": "^2.2.7",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@types/node": "^20.11.21",
"@typescript-eslint/eslint-plugin": "^7.1.0",
"@typescript-eslint/parser": "^7.1.0",
"@types/node": "^20.11.24",
"@typescript-eslint/eslint-plugin": "^7.1.1",
"@typescript-eslint/parser": "^7.1.1",
"eslint": "^8.57.0",
"eslint-plugin-svelte": "^2.35.1",
"kleur": "^4.1.5",
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.1",
"prettier-plugin-svelte": "^3.2.2",
"svelte": "^4.2.12",
"svelte-check": "^3.6.5",
"svelte-check": "^3.6.6",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"uvu": "^0.5.6"
Expand Down
3 changes: 3 additions & 0 deletions src/lib/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ export type Async_Status = 'initial' | 'pending' | 'success' | 'failure';

export const wait = (duration = 0): Promise<void> =>
new Promise((resolve) => setTimeout(resolve, duration));

export const is_promise = (value: any): value is Promise<any> =>
value && typeof value.then === 'function';
2 changes: 1 addition & 1 deletion src/lib/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export const attach_process_error_handlers = (to_error_label?: To_Error_Label):

const handle_fatal_error = async (err: Error, label = 'handle_fatal_error'): Promise<void> => {
new System_Logger(print_log_label(label, red)).error(print_error(err));
await Promise.all(Array.from(global_spawn).map((child) => despawn(child)));
await Promise.all(Array.from(global_spawn, (child) => despawn(child)));
process.exit(1);
};

Expand Down
2 changes: 1 addition & 1 deletion src/lib/timings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test('start and stop multiple overlapping timings', () => {
timings.get('bar');
assert.ok(elapsed.toString().split('.')[1].length <= 4);
assert.equal(
Array.from(timings.entries()).map((e) => e[0]),
Array.from(timings.entries(), (e) => e[0]),
['foo', 'foo_2', 'foo_3'],
);
});
Expand Down
4 changes: 4 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<script lang="ts">
import '@ryanatkn/fuz/style.css';
import '@ryanatkn/fuz/theme.css';
import '@ryanatkn/fuz/semantic_classes.css';
import '@ryanatkn/fuz/utility_classes.css';
import '@ryanatkn/fuz/variable_classes.css';
import '@ryanatkn/fuz/animations.css';
import '$routes/style.css';
import Themed from '@ryanatkn/fuz/Themed.svelte';
Expand Down
13 changes: 7 additions & 6 deletions src/routes/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ export const package_json = {
devDependencies: {
'@changesets/changelog-git': '^0.2.0',
'@ryanatkn/eslint-config': '^0.1.0',
'@ryanatkn/fuz': '^0.91.0',
'@ryanatkn/fuz': '^0.91.3',
'@ryanatkn/gro': '^0.112.4',
'@sveltejs/adapter-static': '^3.0.1',
'@sveltejs/kit': '^2.5.2',
'@sveltejs/package': '^2.2.7',
'@sveltejs/vite-plugin-svelte': '^3.0.2',
'@types/node': '^20.11.21',
'@typescript-eslint/eslint-plugin': '^7.1.0',
'@typescript-eslint/parser': '^7.1.0',
'@types/node': '^20.11.24',
'@typescript-eslint/eslint-plugin': '^7.1.1',
'@typescript-eslint/parser': '^7.1.1',
eslint: '^8.57.0',
'eslint-plugin-svelte': '^2.35.1',
kleur: '^4.1.5',
prettier: '^3.2.5',
'prettier-plugin-svelte': '^3.2.1',
'prettier-plugin-svelte': '^3.2.2',
svelte: '^4.2.12',
'svelte-check': '^3.6.5',
'svelte-check': '^3.6.6',
tslib: '^2.6.2',
typescript: '^5.3.3',
uvu: '^0.5.6',
Expand Down Expand Up @@ -105,6 +105,7 @@ export const src_json = {
declarations: [
{name: 'Async_Status', kind: 'type'},
{name: 'wait', kind: 'function'},
{name: 'is_promise', kind: 'function'},
],
},
'./colors.js': {
Expand Down

0 comments on commit a5d3bb6

Please sign in to comment.