@pluv/persistence-redis 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { AbstractPersistence } from "@pluv/io";
2
2
  import { JsonObject } from "@pluv/types";
3
3
  import { Cluster, Redis } from "ioredis";
4
-
5
4
  //#region src/PersistenceRedis.d.ts
6
5
  type RedisClient = Cluster | Redis;
7
6
  interface PersistenceRedisOptions {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/PersistenceRedis.ts"],"mappings":";;;;;KAUY,WAAA,GAAc,OAAA,GAAU,KAAK;AAAA,UAExB,uBAAA;EACb,MAAA,EAAQ,WAAW;AAAA;AAAA,cAGV,gBAAA,SAAyB,mBAAA;EAAA,QAC1B,OAAA;EAAA,QACA,YAAA;cAEI,OAAA,EAAS,uBAAA;EASR,OAAA,CACT,IAAA,UACA,YAAA,UACA,IAAA,EAAM,UAAA,UACP,OAAA;EAYU,kBAAA,CAAmB,IAAA,WAAe,OAAA;EAQlC,UAAA,CAAW,IAAA,UAAc,YAAA,WAAuB,OAAA;EAmBhD,WAAA,CAAY,IAAA,WAAe,OAAA;EAiB3B,eAAA,CAAgB,IAAA,WAAe,OAAA;EAQ/B,eAAA,CAAgB,IAAA,UAAc,KAAA,WAAgB,OAAA;EAQ9C,OAAA,CAAQ,IAAA,UAAc,YAAA,WAAuB,OAAA,CAAQ,UAAA;EAUrD,QAAA,CACT,IAAA,WACD,OAAA,CAAQ,GAAA,EAAK,YAAA,cAA0B,UAAA;EAqB7B,YAAA,CAAa,IAAA,WAAe,OAAA;EAQlC,UAAA,CAAW,WAAA;EAAA,QAOV,cAAA;EAAA,QAIA,kBAAA;EAAA,QAIA,gBAAA;EAAA,QAIA,oBAAA;AAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/PersistenceRedis.ts"],"mappings":";;;;KAUY,cAAc,UAAU;UAEnB;EACb,QAAQ;;cAGC,yBAAyB;UAC1B;UACA;EAEI,YAAA,SAAS;EASR,QACT,cACA,sBACA,MAAM,oBACP;EAYU,mBAAmB,eAAe;EAQlC,WAAW,cAAc,uBAAuB;EAmBhD,YAAY,eAAe;EAiB3B,gBAAgB,eAAe;EAQ/B,gBAAgB,cAAc,gBAAgB;EAQ9C,QAAQ,cAAc,uBAAuB,QAAQ;EAUrD,SACT,eACD,QAAQ,KAAK,0BAA0B;EAqB7B,aAAa,eAAe;EAQlC,WAAW;UAOV;UAIA;UAIA;UAIA"}
package/dist/index.mjs CHANGED
@@ -2,7 +2,9 @@ import { AbstractPersistence } from "@pluv/io";
2
2
  //#region src/utils/partitionByLength.ts
3
3
  const partitionByLength = (arr, length) => {
4
4
  if (!arr.length) return [];
5
- return [arr.slice(0, length), ...partitionByLength(arr.slice(length), length)];
5
+ const head = arr.slice(0, length);
6
+ const tail = arr.slice(length);
7
+ return [head, ...partitionByLength(tail, length)];
6
8
  };
7
9
  //#endregion
8
10
  //#region src/PersistenceRedis.ts
@@ -62,7 +64,8 @@ var PersistenceRedis = class PersistenceRedis extends AbstractPersistence {
62
64
  async getUsers(room) {
63
65
  if (!this._initialized) return /* @__PURE__ */ new Map();
64
66
  await this._initialized;
65
- return await partitionByLength(await this._client.smembers(this._getRoomUsersKey(room)), GET_USERS_CONCURRENCY).reduce(async (promise, partition) => {
67
+ const members = await this._client.smembers(this._getRoomUsersKey(room));
68
+ return await partitionByLength(members, GET_USERS_CONCURRENCY).reduce(async (promise, partition) => {
66
69
  const map = await promise;
67
70
  const promises = partition.map(async (connectionId) => {
68
71
  map.set(connectionId, await this.getUser(room, connectionId));
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/partitionByLength.ts","../src/PersistenceRedis.ts"],"sourcesContent":["export const partitionByLength = <T>(\n arr: readonly T[] | T[],\n length: number,\n): readonly (readonly T[])[] => {\n if (!arr.length) return [];\n\n const head = arr.slice(0, length);\n const tail = arr.slice(length);\n\n return [head, ...partitionByLength(tail, length)];\n};\n","import { AbstractPersistence } from \"@pluv/io\";\nimport type { JsonObject } from \"@pluv/types\";\nimport type { Cluster, Redis } from \"ioredis\";\nimport { partitionByLength } from \"./utils\";\n\nconst DELIMITER = \":::\";\nconst HASH_TAG = \"{PluvPersistenceRedis}\";\n\nconst GET_USERS_CONCURRENCY = 4;\n\nexport type RedisClient = Cluster | Redis;\n\nexport interface PersistenceRedisOptions {\n client: RedisClient;\n}\n\nexport class PersistenceRedis extends AbstractPersistence {\n private _client: RedisClient;\n private _initialized: Promise<true> | null = null;\n\n constructor(options: PersistenceRedisOptions) {\n super();\n\n const { client } = options;\n\n this._client = client;\n this._initialized = (options as any)._initialized;\n }\n\n public async addUser(\n room: string,\n connectionId: string,\n user: JsonObject | null,\n ): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n await this._client\n .multi()\n .sadd(this._getRoomUsersKey(room), connectionId)\n .set(this._getRoomUsersUserKey(room, connectionId), JSON.stringify(user))\n .exec();\n }\n\n public async deleteStorageState(room: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n await this._client.del(this._getRoomStorageKey(room));\n }\n\n public async deleteUser(room: string, connectionId: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n const size = await this.getUsersSize(room);\n\n let multi = this._client\n .multi()\n .srem(this._getRoomUsersKey(room), connectionId)\n .del(this._getRoomUsersUserKey(room, connectionId));\n\n if (size === 1) {\n multi = multi.del(this._getRoomStorageKey(room)).del(this._getRoomUsersKey(room));\n }\n\n await multi.exec();\n }\n\n public async deleteUsers(room: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n const members = await this._client.smembers(this._getRoomUsersKey(room));\n\n await members\n .reduce(\n (commands, connectionId) => {\n return commands.del(this._getRoomUsersUserKey(room, connectionId));\n },\n this._client.multi().del(this._getRoomUsersKey(room)),\n )\n .exec();\n }\n\n public async getStorageState(room: string): Promise<string | null> {\n if (!this._initialized) return null;\n\n await this._initialized;\n\n return await this._client.get(this._getRoomStorageKey(room));\n }\n\n public async setStorageState(room: string, state: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n await this._client.set(this._getRoomStorageKey(room), state);\n }\n\n public async getUser(room: string, connectionId: string): Promise<JsonObject | null> {\n if (!this._initialized) return null;\n\n await this._initialized;\n\n const data = await this._client.get(this._getRoomUsersUserKey(room, connectionId));\n\n return !data ? null : JSON.parse(data);\n }\n\n public async getUsers(\n room: string,\n ): Promise<Map<[connectionId: string][0], JsonObject | null>> {\n if (!this._initialized) return new Map();\n\n await this._initialized;\n\n const members = await this._client.smembers(this._getRoomUsersKey(room));\n const partitions = partitionByLength(members, GET_USERS_CONCURRENCY);\n\n return await partitions.reduce(async (promise, partition) => {\n const map = await promise;\n\n const promises = partition.map(async (connectionId) => {\n map.set(connectionId, await this.getUser(room, connectionId));\n });\n\n await Promise.all(promises);\n\n return map;\n }, Promise.resolve(new Map<string, JsonObject | null>()));\n }\n\n public async getUsersSize(room: string): Promise<number> {\n if (!this._initialized) return 0;\n\n await this._initialized;\n\n return await this._client.scard(this._getRoomUsersKey(room));\n }\n\n public initialize(roomContext: {}): typeof this {\n return new PersistenceRedis({\n client: this._client,\n ...{ _initialized: Promise.resolve(true as const) },\n }) as typeof this;\n }\n\n private _getClusterKey(key: string): string {\n return `${HASH_TAG}${key}`;\n }\n\n private _getRoomStorageKey(room: string): string {\n return this._getClusterKey(`room_storage${DELIMITER}${room}`);\n }\n\n private _getRoomUsersKey(room: string): string {\n return this._getClusterKey(`room_users${DELIMITER}${room}`);\n }\n\n private _getRoomUsersUserKey(room: string, connectionId: string): string {\n return this._getClusterKey(`${this._getRoomUsersKey(room)}${DELIMITER}${connectionId}`);\n }\n}\n"],"mappings":";;AAAA,MAAa,qBACT,KACA,WAC4B;CAC5B,IAAI,CAAC,IAAI,QAAQ,OAAO,CAAC;CAKzB,OAAO,CAHM,IAAI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rD,IAAI,CAAC,KAAK,cAAc,OAAO;EAE/B,MAAM,KAAK;EAEX,OAAO,MAAM,KAAK,QAAQ,MAAM,KAAK,iBAAiB,IAAI,CAAC;CAC/D;CAEA,WAAkB,aAA8B;EAC5C,OAAO,IAAI,iBAAiB;GACxB,QAAQ,KAAK;GACR,cAAc,QAAQ,QAAQ,IAAa;EACpD,CAAC;CACL;CAEA,eAAuB,KAAqB;EACxC,OAAO,GAAG,WAAW;CACzB;CAEA,mBAA2B,MAAsB;EAC7C,OAAO,KAAK,eAAe,eAAe,YAAY,MAAM;CAChE;CAEA,iBAAyB,MAAsB;EAC3C,OAAO,KAAK,eAAe,aAAa,YAAY,MAAM;CAC9D;CAEA,qBAA6B,MAAc,cAA8B;EACrE,OAAO,KAAK,eAAe,GAAG,KAAK,iBAAiB,IAAI,IAAI,YAAY,cAAc;CAC1F;AACJ"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/utils/partitionByLength.ts","../src/PersistenceRedis.ts"],"sourcesContent":["export const partitionByLength = <T>(\n arr: readonly T[] | T[],\n length: number,\n): readonly (readonly T[])[] => {\n if (!arr.length) return [];\n\n const head = arr.slice(0, length);\n const tail = arr.slice(length);\n\n return [head, ...partitionByLength(tail, length)];\n};\n","import { AbstractPersistence } from \"@pluv/io\";\nimport type { JsonObject } from \"@pluv/types\";\nimport type { Cluster, Redis } from \"ioredis\";\nimport { partitionByLength } from \"./utils\";\n\nconst DELIMITER = \":::\";\nconst HASH_TAG = \"{PluvPersistenceRedis}\";\n\nconst GET_USERS_CONCURRENCY = 4;\n\nexport type RedisClient = Cluster | Redis;\n\nexport interface PersistenceRedisOptions {\n client: RedisClient;\n}\n\nexport class PersistenceRedis extends AbstractPersistence {\n private _client: RedisClient;\n private _initialized: Promise<true> | null = null;\n\n constructor(options: PersistenceRedisOptions) {\n super();\n\n const { client } = options;\n\n this._client = client;\n this._initialized = (options as any)._initialized;\n }\n\n public async addUser(\n room: string,\n connectionId: string,\n user: JsonObject | null,\n ): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n await this._client\n .multi()\n .sadd(this._getRoomUsersKey(room), connectionId)\n .set(this._getRoomUsersUserKey(room, connectionId), JSON.stringify(user))\n .exec();\n }\n\n public async deleteStorageState(room: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n await this._client.del(this._getRoomStorageKey(room));\n }\n\n public async deleteUser(room: string, connectionId: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n const size = await this.getUsersSize(room);\n\n let multi = this._client\n .multi()\n .srem(this._getRoomUsersKey(room), connectionId)\n .del(this._getRoomUsersUserKey(room, connectionId));\n\n if (size === 1) {\n multi = multi.del(this._getRoomStorageKey(room)).del(this._getRoomUsersKey(room));\n }\n\n await multi.exec();\n }\n\n public async deleteUsers(room: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n const members = await this._client.smembers(this._getRoomUsersKey(room));\n\n await members\n .reduce(\n (commands, connectionId) => {\n return commands.del(this._getRoomUsersUserKey(room, connectionId));\n },\n this._client.multi().del(this._getRoomUsersKey(room)),\n )\n .exec();\n }\n\n public async getStorageState(room: string): Promise<string | null> {\n if (!this._initialized) return null;\n\n await this._initialized;\n\n return await this._client.get(this._getRoomStorageKey(room));\n }\n\n public async setStorageState(room: string, state: string): Promise<void> {\n if (!this._initialized) return;\n\n await this._initialized;\n\n await this._client.set(this._getRoomStorageKey(room), state);\n }\n\n public async getUser(room: string, connectionId: string): Promise<JsonObject | null> {\n if (!this._initialized) return null;\n\n await this._initialized;\n\n const data = await this._client.get(this._getRoomUsersUserKey(room, connectionId));\n\n return !data ? null : JSON.parse(data);\n }\n\n public async getUsers(\n room: string,\n ): Promise<Map<[connectionId: string][0], JsonObject | null>> {\n if (!this._initialized) return new Map();\n\n await this._initialized;\n\n const members = await this._client.smembers(this._getRoomUsersKey(room));\n const partitions = partitionByLength(members, GET_USERS_CONCURRENCY);\n\n return await partitions.reduce(async (promise, partition) => {\n const map = await promise;\n\n const promises = partition.map(async (connectionId) => {\n map.set(connectionId, await this.getUser(room, connectionId));\n });\n\n await Promise.all(promises);\n\n return map;\n }, Promise.resolve(new Map<string, JsonObject | null>()));\n }\n\n public async getUsersSize(room: string): Promise<number> {\n if (!this._initialized) return 0;\n\n await this._initialized;\n\n return await this._client.scard(this._getRoomUsersKey(room));\n }\n\n public initialize(roomContext: {}): typeof this {\n return new PersistenceRedis({\n client: this._client,\n ...{ _initialized: Promise.resolve(true as const) },\n }) as typeof this;\n }\n\n private _getClusterKey(key: string): string {\n return `${HASH_TAG}${key}`;\n }\n\n private _getRoomStorageKey(room: string): string {\n return this._getClusterKey(`room_storage${DELIMITER}${room}`);\n }\n\n private _getRoomUsersKey(room: string): string {\n return this._getClusterKey(`room_users${DELIMITER}${room}`);\n }\n\n private _getRoomUsersUserKey(room: string, connectionId: string): string {\n return this._getClusterKey(`${this._getRoomUsersKey(room)}${DELIMITER}${connectionId}`);\n }\n}\n"],"mappings":";;AAAA,MAAa,qBACT,KACA,WAC4B;CAC5B,IAAI,CAAC,IAAI,QAAQ,OAAO,CAAC;CAEzB,MAAM,OAAO,IAAI,MAAM,GAAG,MAAM;CAChC,MAAM,OAAO,IAAI,MAAM,MAAM;CAE7B,OAAO,CAAC,MAAM,GAAG,kBAAkB,MAAM,MAAM,CAAC;AACpD;;;ACLA,MAAM,YAAY;AAClB,MAAM,WAAW;AAEjB,MAAM,wBAAwB;AAQ9B,IAAa,mBAAb,MAAa,yBAAyB,oBAAoB;CACtD;CACA,eAA6C;CAE7C,YAAY,SAAkC;EAC1C,MAAM;EAEN,MAAM,EAAE,WAAW;EAEnB,KAAK,UAAU;EACf,KAAK,eAAgB,QAAgB;CACzC;CAEA,MAAa,QACT,MACA,cACA,MACa;EACb,IAAI,CAAC,KAAK,cAAc;EAExB,MAAM,KAAK;EAEX,MAAM,KAAK,QACN,MAAM,CAAC,CACP,KAAK,KAAK,iBAAiB,IAAI,GAAG,YAAY,CAAC,CAC/C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EACrE,OAAO,KAAK,eAAe,GAAG,KAAK,iBAAiB,IAAI,IAAI,YAAY,cAAc;CAC1F;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pluv/persistence-redis",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "@pluv/io crdt storage persistence for node.js",
5
5
  "author": {
6
6
  "email": "david@pluv.io",
@@ -16,24 +16,27 @@
16
16
  },
17
17
  "type": "module",
18
18
  "types": "./dist/index.d.mts",
19
+ "files": [
20
+ "dist"
21
+ ],
19
22
  "publishConfig": {
20
23
  "access": "public"
21
24
  },
22
25
  "dependencies": {
23
- "@types/node": "^25.9.3",
24
- "@pluv/io": "^5.0.0",
25
- "@pluv/types": "^5.0.0"
26
+ "@pluv/io": "^5.0.2",
27
+ "@pluv/types": "^5.0.2",
28
+ "@types/node": "^26.2.0"
26
29
  },
27
30
  "peerDependencies": {
28
31
  "ioredis": "^5.0.0"
29
32
  },
30
33
  "devDependencies": {
31
- "eslint": "^10.5.0",
32
- "ioredis": "^5.11.1",
33
- "tsdown": "0.22.3",
34
- "typescript": "^5.9.3",
35
- "@pluv/tsconfig": "^5.0.0",
36
- "eslint-config-pluv": "^5.0.0"
34
+ "@pluv/tsconfig": "^5.0.2",
35
+ "eslint": "^10.9.0",
36
+ "eslint-config-pluv": "^5.0.2",
37
+ "ioredis": "^6.0.0",
38
+ "tsdown": "0.22.14",
39
+ "typescript": "^5.9.3"
37
40
  },
38
41
  "exports": {
39
42
  ".": "./dist/index.mjs",
@@ -1,13 +0,0 @@
1
- $ tsdown
2
- ℹ tsdown v0.22.3 powered by rolldown v1.1.2
3
- ℹ config file: /home/runner/work/pluv/pluv/packages/persistence-redis/tsdown.config.ts
4
- ℹ entry: src/index.ts
5
- ℹ target: esnext
6
- ℹ tsconfig: tsconfig.json
7
- ℹ Build start
8
- ℹ dist/index.mjs 3.65 kB │ gzip: 1.00 kB
9
- ℹ dist/index.mjs.map 8.29 kB │ gzip: 2.14 kB
10
- ℹ dist/index.d.mts.map 0.73 kB │ gzip: 0.34 kB
11
- ℹ dist/index.d.mts 1.25 kB │ gzip: 0.46 kB
12
- ℹ 4 files, total: 13.92 kB
13
- ✔ Build complete in 3268ms
package/CHANGELOG.md DELETED
@@ -1,875 +0,0 @@
1
- # @pluv/persistence-redis
2
-
3
- ## 5.0.0
4
-
5
- ### Patch Changes
6
-
7
- - @pluv/io@5.0.0
8
- - @pluv/types@5.0.0
9
-
10
- ## 4.1.0
11
-
12
- ### Patch Changes
13
-
14
- - @pluv/io@4.1.0
15
- - @pluv/types@4.1.0
16
-
17
- ## 4.0.2
18
-
19
- ### Patch Changes
20
-
21
- - e1913b3: Upgraded internal dependencies
22
- - Updated dependencies [e1913b3]
23
- - @pluv/types@4.0.2
24
- - @pluv/io@4.0.2
25
-
26
- ## 4.0.1
27
-
28
- ### Patch Changes
29
-
30
- - @pluv/io@4.0.1
31
- - @pluv/types@4.0.1
32
-
33
- ## 4.0.0
34
-
35
- ### Major Changes
36
-
37
- - df5c39c: Update all packages to be ESM only.
38
-
39
- ### Minor Changes
40
-
41
- - 037074e: Migrated build process from tsup to tsdown.
42
-
43
- ### Patch Changes
44
-
45
- - 2eb5def: Bumped dependencies.
46
- - Updated dependencies [2eb5def]
47
- - Updated dependencies [df5c39c]
48
- - Updated dependencies [c142910]
49
- - Updated dependencies [037074e]
50
- - Updated dependencies [07e2a1e]
51
- - @pluv/types@4.0.0
52
- - @pluv/io@4.0.0
53
-
54
- ## 3.2.2
55
-
56
- ### Patch Changes
57
-
58
- - Updated dependencies [8665dbe]
59
- - @pluv/types@3.2.2
60
- - @pluv/io@3.2.2
61
-
62
- ## 3.2.1
63
-
64
- ### Patch Changes
65
-
66
- - @pluv/io@3.2.1
67
- - @pluv/types@3.2.1
68
-
69
- ## 3.2.0
70
-
71
- ### Patch Changes
72
-
73
- - Updated dependencies [6d2b257]
74
- - @pluv/io@3.2.0
75
- - @pluv/types@3.2.0
76
-
77
- ## 3.1.7
78
-
79
- ### Patch Changes
80
-
81
- - Updated dependencies [f1d56d9]
82
- - @pluv/io@3.1.7
83
- - @pluv/types@3.1.7
84
-
85
- ## 3.1.6
86
-
87
- ### Patch Changes
88
-
89
- - @pluv/io@3.1.6
90
- - @pluv/types@3.1.6
91
-
92
- ## 3.1.5
93
-
94
- ### Patch Changes
95
-
96
- - @pluv/io@3.1.5
97
- - @pluv/types@3.1.5
98
-
99
- ## 3.1.4
100
-
101
- ### Patch Changes
102
-
103
- - @pluv/io@3.1.4
104
- - @pluv/types@3.1.4
105
-
106
- ## 3.1.3
107
-
108
- ### Patch Changes
109
-
110
- - Updated dependencies [651a9f8]
111
- - @pluv/io@3.1.3
112
- - @pluv/types@3.1.3
113
-
114
- ## 3.1.2
115
-
116
- ### Patch Changes
117
-
118
- - Updated dependencies [8f138aa]
119
- - @pluv/io@3.1.2
120
- - @pluv/types@3.1.2
121
-
122
- ## 3.1.1
123
-
124
- ### Patch Changes
125
-
126
- - Updated dependencies [7b719bf]
127
- - @pluv/io@3.1.1
128
- - @pluv/types@3.1.1
129
-
130
- ## 3.1.0
131
-
132
- ### Patch Changes
133
-
134
- - Updated dependencies [a40f4dc]
135
- - @pluv/io@3.1.0
136
- - @pluv/types@3.1.0
137
-
138
- ## 3.0.0
139
-
140
- ### Patch Changes
141
-
142
- - @pluv/io@3.0.0
143
- - @pluv/types@3.0.0
144
-
145
- ## 2.3.1
146
-
147
- ### Patch Changes
148
-
149
- - @pluv/io@2.3.1
150
- - @pluv/types@2.3.1
151
-
152
- ## 2.3.0
153
-
154
- ### Patch Changes
155
-
156
- - @pluv/io@2.3.0
157
- - @pluv/types@2.3.0
158
-
159
- ## 2.2.8
160
-
161
- ### Patch Changes
162
-
163
- - Updated dependencies [b60ccd8]
164
- - @pluv/io@2.2.8
165
- - @pluv/types@2.2.8
166
-
167
- ## 2.2.7
168
-
169
- ### Patch Changes
170
-
171
- - Updated dependencies [ec2717b]
172
- - @pluv/io@2.2.7
173
- - @pluv/types@2.2.7
174
-
175
- ## 2.2.6
176
-
177
- ### Patch Changes
178
-
179
- - @pluv/io@2.2.6
180
- - @pluv/types@2.2.6
181
-
182
- ## 2.2.5
183
-
184
- ### Patch Changes
185
-
186
- - @pluv/io@2.2.5
187
- - @pluv/types@2.2.5
188
-
189
- ## 2.2.4
190
-
191
- ### Patch Changes
192
-
193
- - @pluv/io@2.2.4
194
- - @pluv/types@2.2.4
195
-
196
- ## 2.2.3
197
-
198
- ### Patch Changes
199
-
200
- - @pluv/io@2.2.3
201
- - @pluv/types@2.2.3
202
-
203
- ## 2.2.2
204
-
205
- ### Patch Changes
206
-
207
- - @pluv/io@2.2.2
208
- - @pluv/types@2.2.2
209
-
210
- ## 2.2.1
211
-
212
- ### Patch Changes
213
-
214
- - @pluv/io@2.2.1
215
- - @pluv/types@2.2.1
216
-
217
- ## 2.2.0
218
-
219
- ### Patch Changes
220
-
221
- - Updated dependencies [cb660cd]
222
- - @pluv/io@2.2.0
223
- - @pluv/types@2.2.0
224
-
225
- ## 2.1.0
226
-
227
- ### Patch Changes
228
-
229
- - @pluv/io@2.1.0
230
- - @pluv/types@2.1.0
231
-
232
- ## 2.0.2
233
-
234
- ### Patch Changes
235
-
236
- - @pluv/io@2.0.2
237
- - @pluv/types@2.0.2
238
-
239
- ## 2.0.1
240
-
241
- ### Patch Changes
242
-
243
- - @pluv/io@2.0.1
244
- - @pluv/types@2.0.1
245
-
246
- ## 2.0.0
247
-
248
- ### Patch Changes
249
-
250
- - Updated dependencies [047a1d8]
251
- - @pluv/types@2.0.0
252
- - @pluv/io@2.0.0
253
-
254
- ## 1.0.2
255
-
256
- ### Patch Changes
257
-
258
- - @pluv/io@1.0.2
259
- - @pluv/types@1.0.2
260
-
261
- ## 1.0.1
262
-
263
- ### Patch Changes
264
-
265
- - Updated dependencies [c583be9]
266
- - @pluv/io@1.0.1
267
- - @pluv/types@1.0.1
268
-
269
- ## 1.0.0
270
-
271
- ### Major Changes
272
-
273
- - af94706: pluv.io is now stable and production ready!
274
-
275
- With this v1 release, pluv.io will now follow [semantic versioning](https://semver.org/) with more comprehensive release notes for future changes to the library.
276
-
277
- Checkout the [full documentation here](https://pluv.io/docs/introduction) to get started today!
278
-
279
- ### Patch Changes
280
-
281
- - Updated dependencies [af94706]
282
- - @pluv/io@1.0.0
283
- - @pluv/types@1.0.0
284
-
285
- ## 0.44.2
286
-
287
- ### Patch Changes
288
-
289
- - @pluv/io@0.44.2
290
- - @pluv/types@0.44.2
291
-
292
- ## 0.44.1
293
-
294
- ### Patch Changes
295
-
296
- - @pluv/io@0.44.1
297
- - @pluv/types@0.44.1
298
-
299
- ## 0.44.0
300
-
301
- ### Patch Changes
302
-
303
- - @pluv/io@0.44.0
304
- - @pluv/types@0.44.0
305
-
306
- ## 0.43.0
307
-
308
- ### Patch Changes
309
-
310
- - Updated dependencies [e60a677]
311
- - Updated dependencies [0063e80]
312
- - Updated dependencies [244a973]
313
- - Updated dependencies [4b0fbb3]
314
- - @pluv/io@0.43.0
315
- - @pluv/types@0.43.0
316
-
317
- ## 0.42.0
318
-
319
- ### Minor Changes
320
-
321
- - 4ce32ee: **BREAKING** `Persistence.getUsers` now returns a map of connection id strings to user JSON objects instead of an array of user JSON objects. This change is intended to be internal only and generally non-breaking.
322
-
323
- ### Patch Changes
324
-
325
- - Updated dependencies [cf1529a]
326
- - @pluv/io@0.42.0
327
- - @pluv/types@0.42.0
328
-
329
- ## 0.41.7
330
-
331
- ### Patch Changes
332
-
333
- - @pluv/io@0.41.7
334
- - @pluv/types@0.41.7
335
-
336
- ## 0.41.6
337
-
338
- ### Patch Changes
339
-
340
- - @pluv/io@0.41.6
341
- - @pluv/types@0.41.6
342
-
343
- ## 0.41.5
344
-
345
- ### Patch Changes
346
-
347
- - @pluv/io@0.41.5
348
- - @pluv/types@0.41.5
349
-
350
- ## 0.41.4
351
-
352
- ### Patch Changes
353
-
354
- - @pluv/io@0.41.4
355
- - @pluv/types@0.41.4
356
-
357
- ## 0.41.3
358
-
359
- ### Patch Changes
360
-
361
- - Updated dependencies [49051c0]
362
- - @pluv/io@0.41.3
363
- - @pluv/types@0.41.3
364
-
365
- ## 0.41.2
366
-
367
- ### Patch Changes
368
-
369
- - @pluv/io@0.41.2
370
- - @pluv/types@0.41.2
371
-
372
- ## 0.41.1
373
-
374
- ### Patch Changes
375
-
376
- - @pluv/io@0.41.1
377
- - @pluv/types@0.41.1
378
-
379
- ## 0.41.0
380
-
381
- ### Patch Changes
382
-
383
- - Updated dependencies [73adf21]
384
- - Updated dependencies [f02a430]
385
- - Updated dependencies [0b908b3]
386
- - Updated dependencies [6422f3b]
387
- - Updated dependencies [555b88d]
388
- - Updated dependencies [a663c65]
389
- - Updated dependencies [555b88d]
390
- - @pluv/io@0.41.0
391
- - @pluv/types@0.41.0
392
-
393
- ## 0.40.2
394
-
395
- ### Patch Changes
396
-
397
- - @pluv/io@0.40.2
398
- - @pluv/types@0.40.2
399
-
400
- ## 0.40.1
401
-
402
- ### Patch Changes
403
-
404
- - @pluv/io@0.40.1
405
- - @pluv/types@0.40.1
406
-
407
- ## 0.40.0
408
-
409
- ### Patch Changes
410
-
411
- - @pluv/io@0.40.0
412
- - @pluv/types@0.40.0
413
-
414
- ## 0.39.1
415
-
416
- ### Patch Changes
417
-
418
- - @pluv/io@0.39.1
419
- - @pluv/types@0.39.1
420
-
421
- ## 0.39.0
422
-
423
- ### Patch Changes
424
-
425
- - Updated dependencies [fe6e239]
426
- - Updated dependencies [737d508]
427
- - @pluv/io@0.39.0
428
- - @pluv/types@0.39.0
429
-
430
- ## 0.38.14
431
-
432
- ### Patch Changes
433
-
434
- - @pluv/io@0.38.14
435
- - @pluv/types@0.38.14
436
-
437
- ## 0.38.13
438
-
439
- ### Patch Changes
440
-
441
- - Updated dependencies [809afd3]
442
- - @pluv/io@0.38.13
443
- - @pluv/types@0.38.13
444
-
445
- ## 0.38.12
446
-
447
- ### Patch Changes
448
-
449
- - @pluv/io@0.38.12
450
- - @pluv/types@0.38.12
451
-
452
- ## 0.38.11
453
-
454
- ### Patch Changes
455
-
456
- - @pluv/io@0.38.11
457
- - @pluv/types@0.38.11
458
-
459
- ## 0.38.10
460
-
461
- ### Patch Changes
462
-
463
- - @pluv/io@0.38.10
464
- - @pluv/types@0.38.10
465
-
466
- ## 0.38.9
467
-
468
- ### Patch Changes
469
-
470
- - @pluv/io@0.38.9
471
- - @pluv/types@0.38.9
472
-
473
- ## 0.38.8
474
-
475
- ### Patch Changes
476
-
477
- - @pluv/io@0.38.8
478
- - @pluv/types@0.38.8
479
-
480
- ## 0.38.7
481
-
482
- ### Patch Changes
483
-
484
- - @pluv/io@0.38.7
485
- - @pluv/types@0.38.7
486
-
487
- ## 0.38.6
488
-
489
- ### Patch Changes
490
-
491
- - @pluv/io@0.38.6
492
- - @pluv/types@0.38.6
493
-
494
- ## 0.38.5
495
-
496
- ### Patch Changes
497
-
498
- - @pluv/io@0.38.5
499
- - @pluv/types@0.38.5
500
-
501
- ## 0.38.4
502
-
503
- ### Patch Changes
504
-
505
- - @pluv/io@0.38.4
506
- - @pluv/types@0.38.4
507
-
508
- ## 0.38.3
509
-
510
- ### Patch Changes
511
-
512
- - Updated dependencies [8346273]
513
- - @pluv/io@0.38.3
514
- - @pluv/types@0.38.3
515
-
516
- ## 0.38.2
517
-
518
- ### Patch Changes
519
-
520
- - Updated dependencies [039cd64]
521
- - @pluv/io@0.38.2
522
- - @pluv/types@0.38.2
523
-
524
- ## 0.38.1
525
-
526
- ### Patch Changes
527
-
528
- - @pluv/io@0.38.1
529
- - @pluv/types@0.38.1
530
-
531
- ## 0.38.0
532
-
533
- ### Patch Changes
534
-
535
- - Updated dependencies [f4ceca3]
536
- - @pluv/types@0.38.0
537
- - @pluv/io@0.38.0
538
-
539
- ## 0.37.7
540
-
541
- ### Patch Changes
542
-
543
- - @pluv/io@0.37.7
544
- - @pluv/types@0.37.7
545
-
546
- ## 0.37.6
547
-
548
- ### Patch Changes
549
-
550
- - Updated dependencies [3a874f1]
551
- - @pluv/io@0.37.6
552
- - @pluv/types@0.37.6
553
-
554
- ## 0.37.5
555
-
556
- ### Patch Changes
557
-
558
- - Updated dependencies [9a9ecee]
559
- - @pluv/io@0.37.5
560
- - @pluv/types@0.37.5
561
-
562
- ## 0.37.4
563
-
564
- ### Patch Changes
565
-
566
- - @pluv/io@0.37.4
567
- - @pluv/types@0.37.4
568
-
569
- ## 0.37.3
570
-
571
- ### Patch Changes
572
-
573
- - @pluv/io@0.37.3
574
- - @pluv/types@0.37.3
575
-
576
- ## 0.37.2
577
-
578
- ### Patch Changes
579
-
580
- - @pluv/io@0.37.2
581
- - @pluv/types@0.37.2
582
-
583
- ## 0.37.1
584
-
585
- ### Patch Changes
586
-
587
- - @pluv/io@0.37.1
588
- - @pluv/types@0.37.1
589
-
590
- ## 0.37.0
591
-
592
- ### Patch Changes
593
-
594
- - Updated dependencies [9b74abb]
595
- - @pluv/io@0.37.0
596
- - @pluv/types@0.37.0
597
-
598
- ## 0.36.0
599
-
600
- ### Patch Changes
601
-
602
- - @pluv/io@0.36.0
603
- - @pluv/types@0.36.0
604
-
605
- ## 0.35.4
606
-
607
- ### Patch Changes
608
-
609
- - Updated dependencies [5d3a56f]
610
- - @pluv/io@0.35.4
611
- - @pluv/types@0.35.4
612
-
613
- ## 0.35.3
614
-
615
- ### Patch Changes
616
-
617
- - @pluv/io@0.35.3
618
- - @pluv/types@0.35.3
619
-
620
- ## 0.35.2
621
-
622
- ### Patch Changes
623
-
624
- - Updated dependencies [81cb692]
625
- - @pluv/types@0.35.2
626
- - @pluv/io@0.35.2
627
-
628
- ## 0.35.1
629
-
630
- ### Patch Changes
631
-
632
- - @pluv/io@0.35.1
633
- - @pluv/types@0.35.1
634
-
635
- ## 0.35.0
636
-
637
- ### Patch Changes
638
-
639
- - Updated dependencies [c9073ad]
640
- - @pluv/io@0.35.0
641
- - @pluv/types@0.35.0
642
-
643
- ## 0.34.1
644
-
645
- ### Patch Changes
646
-
647
- - Updated dependencies [d639427]
648
- - @pluv/io@0.34.1
649
- - @pluv/types@0.34.1
650
-
651
- ## 0.34.0
652
-
653
- ### Patch Changes
654
-
655
- - Updated dependencies [0c920ea]
656
- - Updated dependencies [70af3b2]
657
- - @pluv/io@0.34.0
658
- - @pluv/types@0.34.0
659
-
660
- ## 0.33.0
661
-
662
- ### Patch Changes
663
-
664
- - @pluv/io@0.33.0
665
- - @pluv/types@0.33.0
666
-
667
- ## 0.32.9
668
-
669
- ### Patch Changes
670
-
671
- - @pluv/io@0.32.9
672
- - @pluv/types@0.32.9
673
-
674
- ## 0.32.8
675
-
676
- ### Patch Changes
677
-
678
- - Updated dependencies [e659f8a]
679
- - @pluv/io@0.32.8
680
- - @pluv/types@0.32.8
681
-
682
- ## 0.32.7
683
-
684
- ### Patch Changes
685
-
686
- - @pluv/io@0.32.7
687
- - @pluv/types@0.32.7
688
-
689
- ## 0.32.6
690
-
691
- ### Patch Changes
692
-
693
- - Updated dependencies [c0956e7]
694
- - @pluv/io@0.32.6
695
- - @pluv/types@0.32.6
696
-
697
- ## 0.32.5
698
-
699
- ### Patch Changes
700
-
701
- - @pluv/io@0.32.5
702
- - @pluv/types@0.32.5
703
-
704
- ## 0.32.4
705
-
706
- ### Patch Changes
707
-
708
- - @pluv/io@0.32.4
709
- - @pluv/types@0.32.4
710
-
711
- ## 0.32.3
712
-
713
- ### Patch Changes
714
-
715
- - Updated dependencies [bb21274]
716
- - @pluv/io@0.32.3
717
- - @pluv/types@0.32.3
718
-
719
- ## 0.32.2
720
-
721
- ### Patch Changes
722
-
723
- - Updated dependencies [890d45b]
724
- - @pluv/io@0.32.2
725
- - @pluv/types@0.32.2
726
-
727
- ## 0.32.1
728
-
729
- ### Patch Changes
730
-
731
- - @pluv/io@0.32.1
732
- - @pluv/types@0.32.1
733
-
734
- ## 0.32.0
735
-
736
- ### Patch Changes
737
-
738
- - Updated dependencies [cde5305]
739
- - @pluv/io@0.32.0
740
- - @pluv/types@0.32.0
741
-
742
- ## 0.31.0
743
-
744
- ### Patch Changes
745
-
746
- - Updated dependencies [b3c31d7]
747
- - @pluv/io@0.31.0
748
- - @pluv/types@0.31.0
749
-
750
- ## 0.30.2
751
-
752
- ### Patch Changes
753
-
754
- - @pluv/io@0.30.2
755
- - @pluv/types@0.30.2
756
-
757
- ## 0.30.1
758
-
759
- ### Patch Changes
760
-
761
- - Updated dependencies [b9c3633]
762
- - @pluv/io@0.30.1
763
- - @pluv/types@0.30.1
764
-
765
- ## 0.30.0
766
-
767
- ### Patch Changes
768
-
769
- - Updated dependencies [7246a9e]
770
- - @pluv/io@0.30.0
771
- - @pluv/types@0.30.0
772
-
773
- ## 0.29.0
774
-
775
- ### Patch Changes
776
-
777
- - @pluv/io@0.29.0
778
- - @pluv/types@0.29.0
779
-
780
- ## 0.28.0
781
-
782
- ### Patch Changes
783
-
784
- - @pluv/io@0.28.0
785
- - @pluv/types@0.28.0
786
-
787
- ## 0.27.0
788
-
789
- ### Patch Changes
790
-
791
- - Updated dependencies [19ed36c]
792
- - Updated dependencies [e309b0b]
793
- - @pluv/io@0.27.0
794
- - @pluv/types@0.27.0
795
-
796
- ## 0.26.0
797
-
798
- ### Patch Changes
799
-
800
- - @pluv/io@0.26.0
801
- - @pluv/types@0.26.0
802
-
803
- ## 0.25.4
804
-
805
- ### Patch Changes
806
-
807
- - Updated dependencies [7a9080c]
808
- - @pluv/io@0.25.4
809
- - @pluv/types@0.25.4
810
-
811
- ## 0.25.3
812
-
813
- ### Patch Changes
814
-
815
- - Updated dependencies [50d9b96]
816
- - @pluv/io@0.25.3
817
- - @pluv/types@0.25.3
818
-
819
- ## 0.25.2
820
-
821
- ### Patch Changes
822
-
823
- - Updated dependencies [60a0bf1]
824
- - @pluv/io@0.25.2
825
- - @pluv/types@0.25.2
826
-
827
- ## 0.25.1
828
-
829
- ### Patch Changes
830
-
831
- - Updated dependencies [3925f7c]
832
- - @pluv/io@0.25.1
833
- - @pluv/types@0.25.1
834
-
835
- ## 0.25.0
836
-
837
- ### Minor Changes
838
-
839
- - 9db06ba: **BREAKING **
840
-
841
- Fixed typos `persistance` to `persistence`.
842
-
843
- This does mean that all properties referencing `persistance` will need to be fixed. Examples below:
844
-
845
- ```bash
846
- # Re-install @pluv/persistence-redis
847
- pnpm uninstall @pluv/persistance-redis
848
- pnpm install @pluv/persistence-redis
849
- ```
850
-
851
- ```ts
852
- // Before
853
- createIO({
854
- platform: platformNode({
855
- persistance: new PersistanceRedis(/* ... */),
856
- }),
857
- });
858
-
859
- // After
860
- createIO({
861
- platform: platformNode({
862
- persistence: new PersistenceRedis(/* ... */),
863
- }),
864
- });
865
- ```
866
-
867
- `@pluv/persistance-redis` has been deprecated for `@pluv/persistence-redis`.
868
-
869
- ### Patch Changes
870
-
871
- - Updated dependencies [4e078ca]
872
- - Updated dependencies [f556d30]
873
- - Updated dependencies [9db06ba]
874
- - @pluv/io@0.25.0
875
- - @pluv/types@0.25.0
package/eslint.config.mjs DELETED
@@ -1,4 +0,0 @@
1
- import { config } from "eslint-config-pluv/base";
2
-
3
- /** @type {import("eslint").Linter.Config} */
4
- export default config;
@@ -1,169 +0,0 @@
1
- import { AbstractPersistence } from "@pluv/io";
2
- import type { JsonObject } from "@pluv/types";
3
- import type { Cluster, Redis } from "ioredis";
4
- import { partitionByLength } from "./utils";
5
-
6
- const DELIMITER = ":::";
7
- const HASH_TAG = "{PluvPersistenceRedis}";
8
-
9
- const GET_USERS_CONCURRENCY = 4;
10
-
11
- export type RedisClient = Cluster | Redis;
12
-
13
- export interface PersistenceRedisOptions {
14
- client: RedisClient;
15
- }
16
-
17
- export class PersistenceRedis extends AbstractPersistence {
18
- private _client: RedisClient;
19
- private _initialized: Promise<true> | null = null;
20
-
21
- constructor(options: PersistenceRedisOptions) {
22
- super();
23
-
24
- const { client } = options;
25
-
26
- this._client = client;
27
- this._initialized = (options as any)._initialized;
28
- }
29
-
30
- public async addUser(
31
- room: string,
32
- connectionId: string,
33
- user: JsonObject | null,
34
- ): Promise<void> {
35
- if (!this._initialized) return;
36
-
37
- await this._initialized;
38
-
39
- await this._client
40
- .multi()
41
- .sadd(this._getRoomUsersKey(room), connectionId)
42
- .set(this._getRoomUsersUserKey(room, connectionId), JSON.stringify(user))
43
- .exec();
44
- }
45
-
46
- public async deleteStorageState(room: string): Promise<void> {
47
- if (!this._initialized) return;
48
-
49
- await this._initialized;
50
-
51
- await this._client.del(this._getRoomStorageKey(room));
52
- }
53
-
54
- public async deleteUser(room: string, connectionId: string): Promise<void> {
55
- if (!this._initialized) return;
56
-
57
- await this._initialized;
58
-
59
- const size = await this.getUsersSize(room);
60
-
61
- let multi = this._client
62
- .multi()
63
- .srem(this._getRoomUsersKey(room), connectionId)
64
- .del(this._getRoomUsersUserKey(room, connectionId));
65
-
66
- if (size === 1) {
67
- multi = multi.del(this._getRoomStorageKey(room)).del(this._getRoomUsersKey(room));
68
- }
69
-
70
- await multi.exec();
71
- }
72
-
73
- public async deleteUsers(room: string): Promise<void> {
74
- if (!this._initialized) return;
75
-
76
- await this._initialized;
77
-
78
- const members = await this._client.smembers(this._getRoomUsersKey(room));
79
-
80
- await members
81
- .reduce(
82
- (commands, connectionId) => {
83
- return commands.del(this._getRoomUsersUserKey(room, connectionId));
84
- },
85
- this._client.multi().del(this._getRoomUsersKey(room)),
86
- )
87
- .exec();
88
- }
89
-
90
- public async getStorageState(room: string): Promise<string | null> {
91
- if (!this._initialized) return null;
92
-
93
- await this._initialized;
94
-
95
- return await this._client.get(this._getRoomStorageKey(room));
96
- }
97
-
98
- public async setStorageState(room: string, state: string): Promise<void> {
99
- if (!this._initialized) return;
100
-
101
- await this._initialized;
102
-
103
- await this._client.set(this._getRoomStorageKey(room), state);
104
- }
105
-
106
- public async getUser(room: string, connectionId: string): Promise<JsonObject | null> {
107
- if (!this._initialized) return null;
108
-
109
- await this._initialized;
110
-
111
- const data = await this._client.get(this._getRoomUsersUserKey(room, connectionId));
112
-
113
- return !data ? null : JSON.parse(data);
114
- }
115
-
116
- public async getUsers(
117
- room: string,
118
- ): Promise<Map<[connectionId: string][0], JsonObject | null>> {
119
- if (!this._initialized) return new Map();
120
-
121
- await this._initialized;
122
-
123
- const members = await this._client.smembers(this._getRoomUsersKey(room));
124
- const partitions = partitionByLength(members, GET_USERS_CONCURRENCY);
125
-
126
- return await partitions.reduce(async (promise, partition) => {
127
- const map = await promise;
128
-
129
- const promises = partition.map(async (connectionId) => {
130
- map.set(connectionId, await this.getUser(room, connectionId));
131
- });
132
-
133
- await Promise.all(promises);
134
-
135
- return map;
136
- }, Promise.resolve(new Map<string, JsonObject | null>()));
137
- }
138
-
139
- public async getUsersSize(room: string): Promise<number> {
140
- if (!this._initialized) return 0;
141
-
142
- await this._initialized;
143
-
144
- return await this._client.scard(this._getRoomUsersKey(room));
145
- }
146
-
147
- public initialize(roomContext: {}): typeof this {
148
- return new PersistenceRedis({
149
- client: this._client,
150
- ...{ _initialized: Promise.resolve(true as const) },
151
- }) as typeof this;
152
- }
153
-
154
- private _getClusterKey(key: string): string {
155
- return `${HASH_TAG}${key}`;
156
- }
157
-
158
- private _getRoomStorageKey(room: string): string {
159
- return this._getClusterKey(`room_storage${DELIMITER}${room}`);
160
- }
161
-
162
- private _getRoomUsersKey(room: string): string {
163
- return this._getClusterKey(`room_users${DELIMITER}${room}`);
164
- }
165
-
166
- private _getRoomUsersUserKey(room: string, connectionId: string): string {
167
- return this._getClusterKey(`${this._getRoomUsersKey(room)}${DELIMITER}${connectionId}`);
168
- }
169
- }
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export type { RedisClient } from "./PersistenceRedis";
2
- export { PersistenceRedis } from "./PersistenceRedis";
@@ -1 +0,0 @@
1
- export { partitionByLength } from "./partitionByLength";
@@ -1,11 +0,0 @@
1
- export const partitionByLength = <T>(
2
- arr: readonly T[] | T[],
3
- length: number,
4
- ): readonly (readonly T[])[] => {
5
- if (!arr.length) return [];
6
-
7
- const head = arr.slice(0, length);
8
- const tail = arr.slice(length);
9
-
10
- return [head, ...partitionByLength(tail, length)];
11
- };
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "@pluv/tsconfig/library.json",
3
- "include": ["**/*.ts"],
4
- "exclude": ["node_modules"],
5
- "compilerOptions": {
6
- "types": ["@types/node"]
7
- }
8
- }
package/tsdown.config.ts DELETED
@@ -1,14 +0,0 @@
1
- import { defineConfig } from "tsdown";
2
-
3
- export default defineConfig({
4
- format: ["esm"],
5
- dts: true,
6
- outDir: "dist",
7
- entry: "src/index.ts",
8
- target: "esnext",
9
- sourcemap: true,
10
- clean: true,
11
- exports: {
12
- all: true,
13
- },
14
- });