@bothrs/util
Advanced tools
Comparing version 3.0.4 to 3.0.5
@@ -0,1 +1,10 @@ | ||
/** | ||
* | ||
* Manage Airtable data based on standard env variables. | ||
* | ||
* Example: | ||
* | ||
* `await select('Blogposts')` => Load blogposts | ||
* @module | ||
*/ | ||
import { Environment, FieldSet, Packed, SelectOptions, Unpacked } from './airtable'; | ||
@@ -2,0 +11,0 @@ export { byIds, pack, serialize, unpack, where } from './airtable'; |
"use strict"; | ||
/** | ||
* | ||
* Manage Airtable data based on standard env variables. | ||
* | ||
* Example: | ||
* | ||
* `await select('Blogposts')` => Load blogposts | ||
* @module | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -3,0 +12,0 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
@@ -0,1 +1,9 @@ | ||
/** | ||
* Manage Airtable data. | ||
* | ||
* Example: | ||
* | ||
* `await select({ app: '', key: '' }, 'Blogposts')` => Load blogposts | ||
* @module | ||
*/ | ||
import { serialize } from './url'; | ||
@@ -2,0 +10,0 @@ export { serialize }; |
"use strict"; | ||
/** | ||
* Manage Airtable data. | ||
* | ||
* Example: | ||
* | ||
* `await select({ app: '', key: '' }, 'Blogposts')` => Load blogposts | ||
* @module | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -3,0 +11,0 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
@@ -0,1 +1,11 @@ | ||
/** | ||
* Async helpers | ||
* | ||
* Examples: | ||
* | ||
* - `await timeout(1000)` => Wait for 1 second | ||
* - `const busy = await isPending(promise)` => Check if promise is pending | ||
* - `const [error, data] = await to(promise)` => Unwrap promise | ||
* @module | ||
*/ | ||
export declare function timeout(ms: number): Promise<void>; | ||
@@ -2,0 +12,0 @@ export declare function isPending<T>(promise: T): Promise<boolean>; |
10
async.js
"use strict"; | ||
/** | ||
* Async helpers | ||
* | ||
* Examples: | ||
* | ||
* - `await timeout(1000)` => Wait for 1 second | ||
* - `const busy = await isPending(promise)` => Check if promise is pending | ||
* - `const [error, data] = await to(promise)` => Unwrap promise | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +13,0 @@ exports.to = exports.isPending = exports.timeout = void 0; |
@@ -0,1 +1,17 @@ | ||
/** | ||
* Fetch JSON + shorthand for Authorization: Bearer | ||
* | ||
* Note: when using this on a node server, fetch needs to be polyfilled | ||
* node-fetch suggests doing this like: | ||
* | ||
* ```typescript | ||
* import fetch from 'node-fetch' | ||
* | ||
* if (!globalThis.fetch) { | ||
* //@ts-ignore | ||
* globalThis.fetch = fetch | ||
* } | ||
* ``` | ||
* @module | ||
*/ | ||
export declare function fetchJSON(url: string, options?: any): Promise<any>; | ||
@@ -2,0 +18,0 @@ export declare function getJSON(url: string, options?: any): Promise<any>; |
16
fetch.js
"use strict"; | ||
/** | ||
* Fetch JSON + shorthand for Authorization: Bearer | ||
* | ||
* Note: when using this on a node server, fetch needs to be polyfilled | ||
* node-fetch suggests doing this like: | ||
* | ||
* ```typescript | ||
* import fetch from 'node-fetch' | ||
* | ||
* if (!globalThis.fetch) { | ||
* //@ts-ignore | ||
* globalThis.fetch = fetch | ||
* } | ||
* ``` | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +19,0 @@ exports._putJSON = exports._patchJSON = exports.deleteJSON = exports.putJSON = exports.patchJSON = exports.postJSON = exports.getJSON = exports.fetchJSON = void 0; |
@@ -0,1 +1,5 @@ | ||
/** | ||
* Read and write from filesystem using promises. | ||
* @module | ||
*/ | ||
export declare function readFile(fileName: string, type?: string): Promise<string>; | ||
@@ -2,0 +6,0 @@ export declare function writeFile(fileName: string, data: string, type?: string): Promise<unknown>; |
"use strict"; | ||
/** | ||
* Read and write from filesystem using promises. | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +7,0 @@ exports.writeJSON = exports.readJSON = exports.writeFile = exports.readFile = void 0; |
/** | ||
* Minimal helper for localStorage | ||
* | ||
* @module | ||
*/ | ||
/** | ||
* Store a value in localStorage | ||
@@ -3,0 +8,0 @@ * |
"use strict"; | ||
/** | ||
* Minimal helper for localStorage | ||
* | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +8,0 @@ exports.ls = void 0; |
/** | ||
* Optimize common requests. | ||
* @module | ||
*/ | ||
/** | ||
* Memoize function | ||
@@ -3,0 +7,0 @@ * |
"use strict"; | ||
/** | ||
* Optimize common requests. | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +7,0 @@ exports.optimist = exports.memo = void 0; |
{ | ||
"name": "@bothrs/util", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "Common helper functions", | ||
@@ -15,3 +15,3 @@ "license": "MIT", | ||
"preversion": "npm run fix", | ||
"docs": "typedoc --out docs src" | ||
"docs": "typedoc --out docs src --includeVersion" | ||
}, | ||
@@ -18,0 +18,0 @@ "dependencies": {}, |
@@ -0,1 +1,5 @@ | ||
/** | ||
* Generate random strings and UUIDs. | ||
* @module | ||
*/ | ||
export declare function id(len?: number): string; | ||
@@ -2,0 +6,0 @@ export declare function str62(len?: number): string; |
"use strict"; | ||
/** | ||
* Generate random strings and UUIDs. | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +7,0 @@ exports.uuidv4 = exports.char62 = exports.str36 = exports.str62 = exports.id = void 0; |
## Introduction | ||
Here you can find a list of all the main utils being exported by this package. | ||
More in depth, generated, documentation can be found on the [gh pages](https://bothrs.github.io/util/index.html). | ||
The following utils can be imported from `@bothrs/util/<utilname>` | ||
More in depth, generated, documentation can be found on the [gh pages](https://bothrs.github.io/util/). | ||
## util | ||
If you're reading this on the gh pages, use the sidebar on the right! | ||
#### airtable-env | ||
All standard `typescript` modules can be found in the docs, but there are also a lot of mjs files that could be useful. Here's a list of available mjs modules: | ||
Manage Airtable data based on standard env variables. | ||
`await select('Blogposts')` => Load blogposts | ||
#### async.mjs + ts | ||
`await timeout(1000)` => Wait for 1 second | ||
`const busy = await isPending(promise)` => Check if promise is pending | ||
`const [error, data] = await to(promise)` => Unwrap promise | ||
#### airtable.mjs + ts | ||
Manage Airtable data. | ||
`await select({ app: '', key: '' }, 'Blogposts')` => Load blogposts | ||
#### fetch.mjs + ts | ||
Fetch JSON + shorthand for Authorization: Bearer | ||
Note: when using this on a node server, fetch needs to be polyfilled | ||
node-fetch suggests doing this like: | ||
```javascript | ||
import fetch from 'node-fetch' | ||
if (!globalThis.fetch) { | ||
//@ts-ignore | ||
globalThis.fetch = fetch | ||
} | ||
``` | ||
#### fs.mjs + ts | ||
Read and write from filesystem using promises. | ||
#### ls.mjs + ts | ||
Minimal helper for localStorage | ||
#### memo.mjs + ts | ||
Optimize common requests. | ||
#### random.mjs + ts | ||
Generate random strings and UUIDs. | ||
#### uniq.mjs + ts | ||
Filter uniq items from an array. | ||
#### url.mjs + ts | ||
Manage URLs. | ||
`serialize({ example: 'ok' })` => Build a querystring | ||
## mjs | ||
The mjs files contain code that could benefit from | ||
some triage;either refactored into `ts` files or removed. | ||
some triage; either refactored into `ts` files or removed. | ||
@@ -74,0 +15,0 @@ #### airtable-translation.mjs |
@@ -0,2 +1,6 @@ | ||
/** | ||
* Filter uniq items from an array. | ||
* @module | ||
*/ | ||
export declare function uniq<T>(v: T, i: number, a: T[]): boolean; | ||
export declare function uniqBy<T>(prop: keyof T): (v: T, i: number, a: T[]) => boolean; |
"use strict"; | ||
/** | ||
* Filter uniq items from an array. | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +7,0 @@ exports.uniqBy = exports.uniq = void 0; |
@@ -0,1 +1,9 @@ | ||
/** | ||
* Manage URLs. | ||
* | ||
* Example: | ||
* | ||
* - `serialize({ example: 'ok' })` => Build a querystring | ||
* @module | ||
*/ | ||
export declare function serialize(obj: any): string; | ||
@@ -2,0 +10,0 @@ export declare function unserialize(str: string): any; |
"use strict"; | ||
/** | ||
* Manage URLs. | ||
* | ||
* Example: | ||
* | ||
* - `serialize({ example: 'ok' })` => Build a querystring | ||
* @module | ||
*/ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -3,0 +11,0 @@ exports.origin = exports.isUrl = exports.isRelative = exports.isAbsolute = exports.isNamed = exports.resolveUrl = exports.resolveModule = exports.httpUrl = exports.unserialize = exports.serialize = void 0; |
67135
2025
170