proto.io 0.0.204 → 0.0.205

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.
@@ -71,9 +71,9 @@ class FileStorageBase {
71
71
  yield data;
72
72
  }
73
73
  else {
74
- const endBytes = startBytes + data.length;
74
+ const endBytes = startBytes + data.length - 1;
75
75
  const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;
76
- const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;
76
+ const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;
77
77
  yield data.subarray(_start, _end);
78
78
  }
79
79
  }
@@ -81,4 +81,4 @@ class FileStorageBase {
81
81
  }
82
82
 
83
83
  exports.FileStorageBase = FileStorageBase;
84
- //# sourceMappingURL=base-NsJYo2MG.js.map
84
+ //# sourceMappingURL=base-BFKQpiws.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-NsJYo2MG.js","sources":["../../../src/adapters/file/base/base.ts"],"sourcesContent":["//\n// base.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["promisify","_deflate","_unzip","PVK","parallelEach","binaryStreamChunk","parallelMap"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA,MAAM,OAAO,GAAGA,cAAS,CAACC,YAAQ,CAAC;AACnC,MAAM,KAAK,GAAGD,cAAS,CAACE,UAAM,CAAC;MAOT,eAAe,CAAA;AAEnC,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,OAA2B,EAAA;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,EAAE,GAAG,IAAI;AACpB,YAAA,QAAQ,EAAE,CAAC;AACX,YAAA,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvC;;AAGH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,EAAE;;IAUX,MAAM,MAAM,CACV,KAAsB,EACtB,MAA8C,EAC9C,IAAe,EACf,aAAqB,EAAA;QAGrB,MAAM,KAAK,GAAG,KAAK,CAACC,YAAG,CAAC,CAAC,UAAU,EAAE;QAErC,IAAI,IAAI,GAAG,CAAC;AACZ,QAAA,MAAM,OAA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,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAE1C,gBAAA,MAAM,IAAI;;iBAEL;AAEL,gBAAA,MAAM,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM;gBACzC,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,CAAC;gBAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,UAAU,GAAG,SAAS;gBAE7E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
1
+ {"version":3,"file":"base-BFKQpiws.js","sources":["../../../src/adapters/file/base/base.ts"],"sourcesContent":["//\n// base.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length - 1;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["promisify","_deflate","_unzip","PVK","parallelEach","binaryStreamChunk","parallelMap"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA,MAAM,OAAO,GAAGA,cAAS,CAACC,YAAQ,CAAC;AACnC,MAAM,KAAK,GAAGD,cAAS,CAACE,UAAM,CAAC;MAOT,eAAe,CAAA;AAEnC,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,OAA2B,EAAA;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,EAAE,GAAG,IAAI;AACpB,YAAA,QAAQ,EAAE,CAAC;AACX,YAAA,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvC;;AAGH,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,EAAE;;IAUX,MAAM,MAAM,CACV,KAAsB,EACtB,MAA8C,EAC9C,IAAe,EACf,aAAqB,EAAA;QAGrB,MAAM,KAAK,GAAG,KAAK,CAACC,YAAG,CAAC,CAAC,UAAU,EAAE;QAErC,IAAI,IAAI,GAAG,CAAC;AACZ,QAAA,MAAM,OAAO,GAAG,iBAAiB,MAA6B,E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,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAE1C,gBAAA,MAAM,IAAI;;iBAEL;gBAEL,MAAM,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC;gBAC7C,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,CAAC;gBAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,UAAU,GAAG,CAAC,GAAG,SAAS;gBAEjF,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
@@ -69,9 +69,9 @@ class FileStorageBase {
69
69
  yield data;
70
70
  }
71
71
  else {
72
- const endBytes = startBytes + data.length;
72
+ const endBytes = startBytes + data.length - 1;
73
73
  const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;
74
- const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;
74
+ const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;
75
75
  yield data.subarray(_start, _end);
76
76
  }
77
77
  }
@@ -79,4 +79,4 @@ class FileStorageBase {
79
79
  }
80
80
 
81
81
  export { FileStorageBase as F };
82
- //# sourceMappingURL=base-DYc1_peK.mjs.map
82
+ //# sourceMappingURL=base-CfQi0T0I.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-DYc1_peK.mjs","sources":["../../../src/adapters/file/base/base.ts"],"sourcesContent":["//\n// base.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["_deflate","_unzip"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA,MAAM,OAAO,GAAG,SAAS,CAACA,SAAQ,CAAC;AACnC,MAAM,KAAK,GAAG,SAAS,CAACC,OAAM,CAAC;MAOT,eAAe,CAAA;AAEnC,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,OAA2B,EAAA;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,EAAE,GAAG,IAAI;AACpB,YAAA,QAAQ,EAAE,CA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W,CACzB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,CAAC,EACtC,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,OAAM,KAAK,MAAK;YACd,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC;AACpC,SAAA,CAAC,CACH;AAED,QAAA,WAAW,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE;AAEvD,YAAA,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAE1C,gBAAA,MAAM,IAAI;;iBAEL;AAEL,gBAAA,MAAM,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM;gBACzC,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,CAAC;gBAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,UAAU,GAAG,SAAS;gBAE7E,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
1
+ {"version":3,"file":"base-CfQi0T0I.mjs","sources":["../../../src/adapters/file/base/base.ts"],"sourcesContent":["//\n// base.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { promisify } from 'util';\nimport { deflate as _deflate, unzip as _unzip } from 'zlib';\nimport { TFileInfo, TFileStorage } from '../../../server/file';\nimport { ProtoService } from '../../../server/proto';\nimport { TSchema } from '../../../internals/schema';\nimport { BinaryData, binaryStreamChunk, parallelEach, parallelMap } from '@o2ter/utils-js';\nimport { PVK } from '../../../internals/private';\n\nconst deflate = promisify(_deflate);\nconst unzip = promisify(_unzip);\n\nexport type FileStorageOptions = {\n chunkSize?: number;\n parallel?: number;\n};\n\nexport abstract class FileStorageBase implements TFileStorage {\n\n options: Required<FileStorageOptions>;\n\n constructor(options: FileStorageOptions) {\n this.options = {\n chunkSize: 16 * 1024,\n parallel: 8,\n ..._.pickBy(options, v => !_.isNil(v)),\n };\n }\n\n get schema(): Record<string, TSchema> {\n return {}\n }\n\n abstract createChunk<E>(proto: ProtoService<E>, token: string, start: number, end: number, compressed: Buffer): PromiseLike<void>;\n abstract readChunks<E>(proto: ProtoService<E>, token: string, start?: number, end?: number): AsyncGenerator<{\n start: number;\n data: Buffer | Uint8Array | PromiseLike<Buffer | Uint8Array>;\n }, void>;\n abstract destroy<E>(proto: ProtoService<E>, id: string): PromiseLike<void>;\n\n async create<E>(\n proto: ProtoService<E>,\n stream: BinaryData | AsyncIterable<BinaryData>,\n info: TFileInfo,\n maxUploadSize: number,\n ) {\n\n const token = proto[PVK].generateId();\n\n let size = 0;\n const _stream = async function* (stream: AsyncIterable<Buffer>) {\n for await (const data of stream) {\n yield { data, offset: size };\n size += data.byteLength;\n }\n };\n\n await parallelEach(\n _stream(binaryStreamChunk(stream, this.options.chunkSize)),\n this.options.parallel,\n async ({ data, offset }) => {\n const chunkSize = data.byteLength;\n await this.createChunk(proto, token, offset, offset + chunkSize, await deflate(data));\n if (offset + chunkSize > maxUploadSize) throw Error('Payload too large');\n }\n );\n\n return { _id: token, size };\n }\n\n async* fileData<E>(proto: ProtoService<E>, id: string, start?: number, end?: number) {\n\n const _stream = parallelMap(\n this.readChunks(proto, id, start, end),\n this.options.parallel,\n async chunk => ({\n start: chunk.start,\n data: await unzip(await chunk.data),\n })\n );\n\n for await (const { start: startBytes, data } of _stream) {\n\n if (!_.isNumber(start) && !_.isNumber(end)) {\n\n yield data;\n\n } else {\n\n const endBytes = startBytes + data.length - 1;\n const _start = _.isNumber(start) && start > startBytes ? start - startBytes : 0;\n const _end = _.isNumber(end) && end < endBytes ? end - startBytes + 1 : undefined;\n\n yield data.subarray(_start, _end);\n }\n }\n }\n};\n"],"names":["_deflate","_unzip"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAWA,MAAM,OAAO,GAAG,SAAS,CAACA,SAAQ,CAAC;AACnC,MAAM,KAAK,GAAG,SAAS,CAACC,OAAM,CAAC;MAOT,eAAe,CAAA;AAEnC,IAAA,OAAO;AAEP,IAAA,WAAA,CAAY,OAA2B,EAAA;QACrC,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,EAAE,GAAG,IAAI;AACpB,YAAA,QAAQ,EAAE,CAAC;AACX,YAAA,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,IAAI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,GAAG,CAAC,EACtC,IAAI,CAAC,OAAO,CAAC,QAAQ,EACrB,OAAM,KAAK,MAAK;YACd,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI,EAAE,MAAM,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC;AACpC,SAAA,CAAC,CACH;AAED,QAAA,WAAW,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,OAAO,EAAE;AAEvD,YAAA,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;AAE1C,gBAAA,MAAM,IAAI;;iBAEL;gBAEL,MAAM,QAAQ,GAAG,UAAU,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC;gBAC7C,MAAM,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,CAAC;gBAC/E,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,QAAQ,GAAG,GAAG,GAAG,UAAU,GAAG,CAAC,GAAG,SAAS;gBAEjF,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;;;;AAIxC;;;;"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var _ = require('lodash');
4
- var base = require('./base-NsJYo2MG.js');
4
+ var base = require('./base-BFKQpiws.js');
5
5
 
6
6
  //
7
7
  // object.ts
@@ -46,4 +46,4 @@ class FileChunkStorageBase extends base.FileStorageBase {
46
46
  }
47
47
 
48
48
  exports.FileChunkStorageBase = FileChunkStorageBase;
49
- //# sourceMappingURL=chunk-CdEGTub2.js.map
49
+ //# sourceMappingURL=chunk-BuMQw4dz.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-CdEGTub2.js","sources":["../../../src/adapters/file/base/chunk.ts"],"sourcesContent":["//\n// object.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { FileStorageBase } from './base';\nimport { ProtoService } from '../../../server/proto';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{\n start: number;\n file: File;\n }[]>;\n\n abstract readChunk<E>(proto: ProtoService<E>, file: File): PromiseLike<Buffer>;\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const files = _.orderBy(await this.listChunks(proto, token), x => x.start);\n for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {\n if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes) continue;\n if (_.isNumber(end) && end <= chunk!.start) continue;\n if (!chunk) continue;\n yield {\n start: chunk.start,\n data: (async () => this.readChunk(proto, chunk.file))(),\n };\n }\n }\n}"],"names":["FileStorageBase"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMM,MAAgB,oBAA2B,SAAQA,oBAAe,CAAA;IAStE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAA0B,EAAE,GAAwB,EAAA;QAC9G,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAC1E,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;AACpF,YAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,QAAQ;gBAAE;YACpE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,KAAM,CAAC,KAAK;gBAAE;AAC5C,YAAA,IAAI,CAAC,KAAK;gBAAE;YACZ,MAAM;gBACJ,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,gBAAA,IAAI,EAAE,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG;aACxD;;;AAGN;;;;"}
1
+ {"version":3,"file":"chunk-BuMQw4dz.js","sources":["../../../src/adapters/file/base/chunk.ts"],"sourcesContent":["//\n// object.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { FileStorageBase } from './base';\nimport { ProtoService } from '../../../server/proto';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{\n start: number;\n file: File;\n }[]>;\n\n abstract readChunk<E>(proto: ProtoService<E>, file: File): PromiseLike<Buffer>;\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const files = _.orderBy(await this.listChunks(proto, token), x => x.start);\n for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {\n if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes) continue;\n if (_.isNumber(end) && end <= chunk!.start) continue;\n if (!chunk) continue;\n yield {\n start: chunk.start,\n data: (async () => this.readChunk(proto, chunk.file))(),\n };\n }\n }\n}"],"names":["FileStorageBase"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMM,MAAgB,oBAA2B,SAAQA,oBAAe,CAAA;IAStE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAA0B,EAAE,GAAwB,EAAA;QAC9G,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAC1E,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;AACpF,YAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,QAAQ;gBAAE;YACpE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,KAAM,CAAC,KAAK;gBAAE;AAC5C,YAAA,IAAI,CAAC,KAAK;gBAAE;YACZ,MAAM;gBACJ,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,gBAAA,IAAI,EAAE,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG;aACxD;;;AAGN;;;;"}
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { F as FileStorageBase } from './base-DYc1_peK.mjs';
2
+ import { F as FileStorageBase } from './base-CfQi0T0I.mjs';
3
3
 
4
4
  //
5
5
  // object.ts
@@ -44,4 +44,4 @@ class FileChunkStorageBase extends FileStorageBase {
44
44
  }
45
45
 
46
46
  export { FileChunkStorageBase as F };
47
- //# sourceMappingURL=chunk-3nNdftWC.mjs.map
47
+ //# sourceMappingURL=chunk-DxYhYVky.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"chunk-3nNdftWC.mjs","sources":["../../../src/adapters/file/base/chunk.ts"],"sourcesContent":["//\n// object.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { FileStorageBase } from './base';\nimport { ProtoService } from '../../../server/proto';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{\n start: number;\n file: File;\n }[]>;\n\n abstract readChunk<E>(proto: ProtoService<E>, file: File): PromiseLike<Buffer>;\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const files = _.orderBy(await this.listChunks(proto, token), x => x.start);\n for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {\n if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes) continue;\n if (_.isNumber(end) && end <= chunk!.start) continue;\n if (!chunk) continue;\n yield {\n start: chunk.start,\n data: (async () => this.readChunk(proto, chunk.file))(),\n };\n }\n }\n}"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMM,MAAgB,oBAA2B,SAAQ,eAAe,CAAA;IAStE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAA0B,EAAE,GAAwB,EAAA;QAC9G,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAC1E,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;AACpF,YAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,QAAQ;gBAAE;YACpE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,KAAM,CAAC,KAAK;gBAAE;AAC5C,YAAA,IAAI,CAAC,KAAK;gBAAE;YACZ,MAAM;gBACJ,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,gBAAA,IAAI,EAAE,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG;aACxD;;;AAGN;;;;"}
1
+ {"version":3,"file":"chunk-DxYhYVky.mjs","sources":["../../../src/adapters/file/base/chunk.ts"],"sourcesContent":["//\n// object.ts\n//\n// The MIT License\n// Copyright (c) 2021 - 2025 O2ter Limited. All rights reserved.\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the \"Software\"), to deal\n// in the Software without restriction, including without limitation the rights\n// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n// copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n// THE SOFTWARE.\n//\n\nimport _ from 'lodash';\nimport { FileStorageBase } from './base';\nimport { ProtoService } from '../../../server/proto';\n\nexport abstract class FileChunkStorageBase<File> extends FileStorageBase {\n\n abstract listChunks<E>(proto: ProtoService<E>, token: string): PromiseLike<{\n start: number;\n file: File;\n }[]>;\n\n abstract readChunk<E>(proto: ProtoService<E>, file: File): PromiseLike<Buffer>;\n\n async* readChunks<E>(proto: ProtoService<E>, token: string, start?: number | undefined, end?: number | undefined) {\n const files = _.orderBy(await this.listChunks(proto, token), x => x.start);\n for (const [chunk, endBytes] of _.zip(files, _.slice(_.map(files, x => x.start), 1))) {\n if (_.isNumber(start) && _.isNumber(endBytes) && start >= endBytes) continue;\n if (_.isNumber(end) && end <= chunk!.start) continue;\n if (!chunk) continue;\n yield {\n start: chunk.start,\n data: (async () => this.readChunk(proto, chunk.file))(),\n };\n }\n }\n}"],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMM,MAAgB,oBAA2B,SAAQ,eAAe,CAAA;IAStE,OAAO,UAAU,CAAI,KAAsB,EAAE,KAAa,EAAE,KAA0B,EAAE,GAAwB,EAAA;QAC9G,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC;AAC1E,QAAA,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;AACpF,YAAA,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,QAAQ;gBAAE;YACpE,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,KAAM,CAAC,KAAK;gBAAE;AAC5C,YAAA,IAAI,CAAC,KAAK;gBAAE;YACZ,MAAM;gBACJ,KAAK,EAAE,KAAK,CAAC,KAAK;AAClB,gBAAA,IAAI,EAAE,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG;aACxD;;;AAGN;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proto.io",
3
- "version": "0.0.204",
3
+ "version": "0.0.205",
4
4
  "main": "dist/index",
5
5
  "module": "dist/index",
6
6
  "types": "dist/index",