Skip to content

Commit da2b6d4

Browse files
committed
feat(packages): add @stenodb/lodash
1 parent 4835cfb commit da2b6d4

File tree

6 files changed

+180
-66
lines changed

6 files changed

+180
-66
lines changed

packages/lodash/package.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "@stenodb/lodash",
3+
"version": "0.0.0",
4+
"type": "module",
5+
"exports": {
6+
".": {
7+
"types": "./dist/index.d.ts",
8+
"require": "./dist/index.cjs",
9+
"default": "./dist/index.esm.js"
10+
},
11+
"./node": {
12+
"types": "./dist/node.d.ts",
13+
"require": "./dist/node.cjs",
14+
"default": "./dist/node.esm.js"
15+
},
16+
"./browser": {
17+
"types": "./dist/browser.d.ts",
18+
"require": "./dist/browser.cjs",
19+
"default": "./dist/browser.esm.js"
20+
}
21+
},
22+
"types": "./dist/index.d.ts",
23+
"main": "./dist/index.cjs",
24+
"module": "./dist/index.esm.js",
25+
"files": [
26+
"dist",
27+
"src"
28+
],
29+
"scripts": {
30+
"dev": "microbundle watch",
31+
"build": "del-cli dist && microbundle -i src/*.ts --format esm,cjs"
32+
},
33+
"dependencies": {
34+
"@stenodb/browser": "^3.2.0",
35+
"@stenodb/node": "^3.2.0",
36+
"@types/lodash": "4.14.191",
37+
"lodash": "4.17.21"
38+
},
39+
"peerDependencies": {
40+
"@stenodb/browser": "^3.2.0",
41+
"@stenodb/node": "^3.2.0",
42+
"@types/lodash": "^4.14.191",
43+
"lodash": "^4.17.21"
44+
},
45+
"engines": {
46+
"node": ">=14.16"
47+
}
48+
}

packages/lodash/src/browser.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import lodash from 'lodash'
2+
import type { Steno } from '@stenodb/browser'
3+
4+
export class BrowserLodash<T> {
5+
#provider: Steno.BrowserProvider<T>
6+
#chain: lodash.ExpChain<T>
7+
8+
constructor(provider: Steno.BrowserProvider<T>) {
9+
this.#provider = provider
10+
this.#chain = lodash.chain(provider).get('data')
11+
}
12+
13+
get data(): lodash.ExpChain<T> {
14+
return this.#chain
15+
}
16+
17+
read(): T | null {
18+
return this.#provider.read()
19+
}
20+
21+
write(): void {
22+
this.#provider.write()
23+
}
24+
25+
reset(): void {
26+
this.#provider.reset()
27+
}
28+
}

packages/lodash/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './node.js'
2+
export * from './browser.js'

packages/lodash/src/node.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import lodash from 'lodash'
2+
import type { Steno } from '@stenodb/node'
3+
4+
export class NodeLodash<T> {
5+
#provider: Steno.NodeProvider<T>
6+
#chain: lodash.ExpChain<T>
7+
8+
constructor(provider: Steno.NodeProvider<T>) {
9+
this.#provider = provider
10+
this.#chain = lodash.chain(provider).get('data')
11+
}
12+
13+
get data(): lodash.ExpChain<T> {
14+
return this.#chain
15+
}
16+
17+
async read(): Promise<T | null> {
18+
return await this.#provider.read()
19+
}
20+
21+
async write(): Promise<void> {
22+
await this.#provider.write()
23+
}
24+
25+
async reset(): Promise<void> {
26+
await this.#provider.reset()
27+
}
28+
}

packages/lodash/tsconfig.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "@crashmax/tsconfig",
3+
"compilerOptions": {
4+
"moduleResolution": "NodeNext",
5+
"outDir": "dist"
6+
},
7+
"include": [
8+
"src"
9+
]
10+
}

0 commit comments

Comments
 (0)