diff --git a/README.md b/README.md index 6e9b2ca..309fe36 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # protons -[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) -[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) [![codecov](https://img.shields.io/codecov/c/github/ipfs/protons.svg?style=flat-square)](https://codecov.io/gh/ipfs/protons) -[![CI](https://img.shields.io/github/workflow/status/ipfs/protons/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/protons/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) > Protobuf to ts transpiler @@ -12,9 +11,8 @@ - [Structure](#structure) - [Packages](#packages) -- [Contribute](#contribute) - [License](#license) -- [Contribute](#contribute-1) +- [Contribute](#contribute) ## Structure @@ -30,14 +28,6 @@ Transpiles `.proto` files to `.ts` - uses `Uint8Array` for `byte` fields and `Bi - [`/packages/protons-benchmark`](./packages/protons-benchmark) A benchmark suite - [`/packages/protons-runtime`](./packages/protons-runtime) Shared components that turn values to bytes and back again -## Contribute - -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/protons/issues)! - -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). - -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md) - ## License Licensed under either of @@ -47,8 +37,12 @@ Licensed under either of ## Contribute -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)! +Contributions welcome! Please check out [the issues](https://github.com/ipfs/protons/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/lerna.json b/lerna.json deleted file mode 100644 index d7a2336..0000000 --- a/lerna.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "lerna": "4.0.0", - "useWorkspaces": true, - "version": "independent", - "command": { - "run": { - "stream": true - } - } -} diff --git a/package.json b/package.json index 99a253c..d5be1af 100644 --- a/package.json +++ b/package.json @@ -21,24 +21,23 @@ }, "private": true, "scripts": { - "reset": "lerna run clean && rimraf ./node_modules ./package-lock.json packages/*/node_modules packages/*/package-lock.json packages/*/dist", - "test": "lerna run --concurrency 1 test -- --", - "test:node": "lerna run --concurrency 1 test:node -- --", - "test:chrome": "lerna run --concurrency 1 test:chrome -- --", - "test:chrome-webworker": "lerna --concurrency 1 run test:chrome-webworker -- --", - "test:firefox": "lerna run --concurrency 1 test:firefox -- --", - "test:firefox-webworker": "lerna run --concurrency 1 test:firefox-webworker -- --", - "test:electron-main": "lerna run --concurrency 1 test:electron-main -- --", - "test:electron-renderer": "lerna run --concurrency 1 test:electron-renderer -- --", - "clean": "lerna run clean", - "build": "lerna run build", - "lint": "lerna run lint", - "dep-check": "lerna run dep-check", - "release": "lerna run release --concurrency 1 -- --" + "reset": "aegir run clean && aegir clean ./node_modules ./package-lock.json packages/*/node_modules packages/*/package-lock.json packages/*/dist", + "test": "aegir run test", + "test:node": "aegir run test:node", + "test:chrome": "aegir run test:chrome", + "test:chrome-webworker": "aegir run test:chrome-webworker", + "test:firefox": "aegir run test:firefox", + "test:firefox-webworker": "aegir run test:firefox-webworker", + "test:electron-main": "aegir run test:electron-main", + "test:electron-renderer": "aegir run test:electron-renderer", + "clean": "aegir run clean", + "build": "aegir run build", + "lint": "aegir run lint", + "dep-check": "aegir run dep-check", + "release": "aegir run release" }, "dependencies": { - "lerna": "^6.0.0", - "rimraf": "^3.0.2" + "aegir": "^38.0.0" }, "workspaces": [ "packages/*" diff --git a/packages/protons-benchmark/README.md b/packages/protons-benchmark/README.md index d589ee9..5f50673 100644 --- a/packages/protons-benchmark/README.md +++ b/packages/protons-benchmark/README.md @@ -1,10 +1,9 @@ # protons-benchmark -[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) -[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) [![codecov](https://img.shields.io/codecov/c/github/ipfs/protons.svg?style=flat-square)](https://codecov.io/gh/ipfs/protons) -[![CI](https://img.shields.io/github/workflow/status/ipfs/protons/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/protons/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) > Protobuf to ts transpiler @@ -80,8 +79,12 @@ Licensed under either of ## Contribute -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)! +Contributions welcome! Please check out [the issues](https://github.com/ipfs/protons/issues). -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). + +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/protons-benchmark/package.json b/packages/protons-benchmark/package.json index f098d80..e6306a7 100644 --- a/packages/protons-benchmark/package.json +++ b/packages/protons-benchmark/package.json @@ -35,7 +35,7 @@ }, "files": [ "src", - "dist/src", + "dist", "!dist/test", "!**/*.tsbuildinfo" ], @@ -63,7 +63,7 @@ "scripts": { "clean": "aegir clean", "lint": "aegir lint", - "dep-check": "aegir dep-check", + "dep-check": "aegir dep-check --ignore @protobuf-ts/plugin pbjs protons", "build": "aegir build --no-bundle && cp -R src/protobufjs dist/src/protobufjs", "prestart": "npm run build", "start": "node dist/src/index.js", @@ -73,12 +73,13 @@ "@protobuf-ts/plugin": "^2.8.1", "@protobuf-ts/runtime": "^2.8.1", "@types/benchmark": "^2.1.1", - "aegir": "^37.0.5", + "aegir": "^38.0.0", "benchmark": "^2.1.4", "pbjs": "^0.0.14", "protobufjs": "^7.0.0", "protons": "^6.0.0", "protons-runtime": "^4.0.0", + "uint8arraylist": "^2.4.3", "uint8arrays": "^4.0.2" }, "private": true diff --git a/packages/protons-benchmark/src/index.ts b/packages/protons-benchmark/src/index.ts index a79345d..abfad85 100644 --- a/packages/protons-benchmark/src/index.ts +++ b/packages/protons-benchmark/src/index.ts @@ -26,7 +26,7 @@ const message = { payload: Uint8Array.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) } -function expectDecodedCorrectly (result: any) { +function expectDecodedCorrectly (result: any): void { expect(result).to.have.nested.property('meh.lol', message.meh.lol) expect(result).to.have.nested.property('meh.b.tmp.baz', message.meh.b.tmp.baz) expect(result).to.have.property('hello', message.hello) diff --git a/packages/protons-benchmark/src/protons/bench.ts b/packages/protons-benchmark/src/protons/bench.ts index 693cd59..8347fd5 100644 --- a/packages/protons-benchmark/src/protons/bench.ts +++ b/packages/protons-benchmark/src/protons/bench.ts @@ -3,7 +3,7 @@ /* eslint-disable @typescript-eslint/no-namespace */ /* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */ -import { encodeMessage, decodeMessage, message, writer, enumeration } from 'protons-runtime' +import { encodeMessage, decodeMessage, message, enumeration } from 'protons-runtime' import type { Uint8ArrayList } from 'uint8arraylist' import type { Codec } from 'protons-runtime' @@ -78,17 +78,10 @@ export namespace Bar { } if (obj.tmp != null) { - const mw = writer() - Foo.codec().encode(obj.tmp, mw, { - lengthDelimited: false, + w.uint32(10) + Foo.codec().encode(obj.tmp, w, { writeDefaults: false }) - const buf = mw.finish() - - if (buf.byteLength > 0) { - w.uint32(10) - w.bytes(buf) - } } if (opts.lengthDelimited !== false) { @@ -141,7 +134,7 @@ enum __FOOValues { } export namespace FOO { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__FOOValues) } } @@ -226,17 +219,10 @@ export namespace Lol { } if (obj.b != null) { - const mw = writer() - Bar.codec().encode(obj.b, mw, { - lengthDelimited: false, + w.uint32(18) + Bar.codec().encode(obj.b, w, { writeDefaults: false }) - const buf = mw.finish() - - if (buf.byteLength > 0) { - w.uint32(18) - w.bytes(buf) - } } if (opts.lengthDelimited !== false) { @@ -297,17 +283,10 @@ export namespace Test { } if (obj.meh != null) { - const mw = writer() - Lol.codec().encode(obj.meh, mw, { - lengthDelimited: false, + w.uint32(50) + Lol.codec().encode(obj.meh, w, { writeDefaults: false }) - const buf = mw.finish() - - if (buf.byteLength > 0) { - w.uint32(50) - w.bytes(buf) - } } if (obj.hello != null) { diff --git a/packages/protons-runtime/README.md b/packages/protons-runtime/README.md index 3f6bb89..0c8a23f 100644 --- a/packages/protons-runtime/README.md +++ b/packages/protons-runtime/README.md @@ -1,19 +1,17 @@ # protons-runtime -[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) -[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) [![codecov](https://img.shields.io/codecov/c/github/ipfs/protons.svg?style=flat-square)](https://codecov.io/gh/ipfs/protons) -[![CI](https://img.shields.io/github/workflow/status/ipfs/protons/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/protons/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) > Shared code to make your bundle smaller when running protons in your app ## Table of contents - [Install](#install) -- [Contribute](#contribute) - [License](#license) -- [Contribute](#contribute-1) +- [Contribute](#contribute) ## Install @@ -23,14 +21,6 @@ $ npm i protons-runtime Contains shared code to reduce code duplication between modules transpiled by protons. -## Contribute - -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/protons/issues)! - -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). - -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md) - ## License Licensed under either of @@ -40,8 +30,12 @@ Licensed under either of ## Contribute -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)! +Contributions welcome! Please check out [the issues](https://github.com/ipfs/protons/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/protons-runtime/package.json b/packages/protons-runtime/package.json index b290a70..425d0e1 100644 --- a/packages/protons-runtime/package.json +++ b/packages/protons-runtime/package.json @@ -35,7 +35,7 @@ }, "files": [ "src", - "dist/src", + "dist", "!dist/test", "!**/*.tsbuildinfo" ], @@ -149,12 +149,12 @@ }, "dependencies": { "protobufjs": "^7.0.0", - "uint8arraylist": "^2.3.2" + "uint8arraylist": "^2.4.3" + }, + "devDependencies": { + "aegir": "^38.0.0" }, "peerDependencies": { "uint8arraylist": "^2.3.2" - }, - "devDependencies": { - "aegir": "^37.0.5" } } diff --git a/packages/protons-runtime/src/utils.ts b/packages/protons-runtime/src/utils.ts index cce23c9..9c75ba2 100644 --- a/packages/protons-runtime/src/utils.ts +++ b/packages/protons-runtime/src/utils.ts @@ -10,7 +10,7 @@ import WriterBufferClass from 'protobufjs/src/writer_buffer.js' import util from 'protobufjs/src/util/minimal.js' import type { Reader, Writer } from './index.js' -function configure () { +function configure (): void { util._configure() ReaderClass._configure(ReaderBufferClass) WriterClass._configure(WriterBufferClass) diff --git a/packages/protons/README.md b/packages/protons/README.md index 15c626d..b8ccd17 100644 --- a/packages/protons/README.md +++ b/packages/protons/README.md @@ -1,10 +1,9 @@ # protons -[![ipfs.io](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](http://ipfs.io) -[![IRC](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](http://webchat.freenode.net/?channels=%23ipfs) -[![Discord](https://img.shields.io/discord/806902334369824788?style=flat-square)](https://discord.gg/ipfs) +[![ipfs.tech](https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square)](https://ipfs.tech) +[![Discuss](https://img.shields.io/discourse/https/discuss.ipfs.tech/posts.svg?style=flat-square)](https://discuss.ipfs.tech) [![codecov](https://img.shields.io/codecov/c/github/ipfs/protons.svg?style=flat-square)](https://codecov.io/gh/ipfs/protons) -[![CI](https://img.shields.io/github/workflow/status/ipfs/protons/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml) +[![CI](https://img.shields.io/github/actions/workflow/status/ipfs/protons/js-test-and-release.yml?branch=master\&style=flat-square)](https://github.com/ipfs/protons/actions/workflows/js-test-and-release.yml?query=branch%3Amaster) > Protobuf to ts transpiler @@ -13,9 +12,9 @@ - [Install](#install) - [Usage](#usage) - [Differences from protobuf.js](#differences-from-protobufjs) -- [Contribute](#contribute) +- [Missing features](#missing-features) - [License](#license) -- [Contribute](#contribute-1) +- [Contribute](#contribute) ## Install @@ -71,18 +70,10 @@ It does have one or two differences: 3. Unset `optional` fields are set on the deserialized object forms as `undefined` instead of the default values 4. `singular` fields set to default values are not serialized and are set to default values when deserialized if not set - protobuf.js [diverges from the language guide](https://github.com/protobufjs/protobuf.js/issues/1468#issuecomment-745177012) around this feature -## Missing features +## Missing features Some features are missing `OneOf`, `Map`s, etc due to them not being needed so far in ipfs/libp2p. If these features are important to you, please open PRs implementing them along with tests comparing the generated bytes to `protobuf.js` and `pbjs`. -## Contribute - -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/protons/issues)! - -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). - -[![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/contributing.md) - ## License Licensed under either of @@ -92,8 +83,12 @@ Licensed under either of ## Contribute -Feel free to join in. All welcome. Open an [issue](https://github.com/ipfs/js-ipfs-unixfs-importer/issues)! +Contributions welcome! Please check out [the issues](https://github.com/ipfs/protons/issues). + +Also see our [contributing document](https://github.com/ipfs/community/blob/master/CONTRIBUTING_JS.md) for more information on how we work, and about contributing in general. + +Please be aware that all interactions related to this repo are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). -This repository falls under the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md). +Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. [![](https://cdn.rawgit.com/jbenet/contribute-ipfs-gif/master/img/contribute.gif)](https://github.com/ipfs/community/blob/master/CONTRIBUTING.md) diff --git a/packages/protons/bin/protons.ts b/packages/protons/bin/protons.ts index a2ce94c..23ceee2 100644 --- a/packages/protons/bin/protons.ts +++ b/packages/protons/bin/protons.ts @@ -3,7 +3,7 @@ import meow from 'meow' import { generate } from '../src/index.js' -async function main () { +async function main (): Promise { const cli = meow(` Usage $ protons source... diff --git a/packages/protons/package.json b/packages/protons/package.json index 6b35738..e35e681 100644 --- a/packages/protons/package.json +++ b/packages/protons/package.json @@ -38,7 +38,7 @@ }, "files": [ "src", - "dist/src", + "dist", "!dist/test", "!**/*.tsbuildinfo" ], @@ -157,7 +157,7 @@ "protobufjs-cli": "^1.0.0" }, "devDependencies": { - "aegir": "^37.0.5", + "aegir": "^38.0.0", "long": "^5.2.0", "pbjs": "^0.0.14", "protobufjs": "^7.0.0", diff --git a/packages/protons/src/index.ts b/packages/protons/src/index.ts index 49cf75a..246bd95 100644 --- a/packages/protons/src/index.ts +++ b/packages/protons/src/index.ts @@ -14,7 +14,7 @@ export enum CODEC_TYPES { BIT32 } -function pathWithExtension (input: string, extension: string, outputDir?: string) { +function pathWithExtension (input: string, extension: string, outputDir?: string): string { const output = outputDir ?? path.dirname(input) return path.join(output, path.basename(input).split('.').slice(0, -1).join('.') + extension) } @@ -282,7 +282,7 @@ interface FieldDef { enum: boolean } -function defineFields (fields: Record, messageDef: MessageDef, moduleDef: ModuleDef) { +function defineFields (fields: Record, messageDef: MessageDef, moduleDef: ModuleDef): string[] { return Object.entries(fields).map(([fieldName, fieldDef]) => { return `${fieldName}${fieldDef.optional ? '?' : ''}: ${findTypeName(fieldDef.type, messageDef, moduleDef)}${fieldDef.repeated ? '[]' : ''}` }) @@ -310,7 +310,7 @@ enum __${messageDef.name}Values { } export namespace ${messageDef.name} { - export const codec = () => { + export const codec = (): Codec<${messageDef.name}> => { return enumeration<${messageDef.name}>(__${messageDef.name}Values) } }`.trim() @@ -526,7 +526,7 @@ function defineModule (def: ClassDef): ModuleDef { throw new Error('No top-level messages found in protobuf') } - function defineMessage (defs: Record, parent?: ClassDef) { + function defineMessage (defs: Record, parent?: ClassDef): void { for (const className of Object.keys(defs)) { const classDef = defs[className] @@ -589,7 +589,7 @@ interface Flags { output?: string } -export async function generate (source: string, flags: Flags) { +export async function generate (source: string, flags: Flags): Promise { // convert .protobuf to .json const json = await promisify(pbjs)(['-t', 'json', source]) diff --git a/packages/protons/test/fixtures/circuit.ts b/packages/protons/test/fixtures/circuit.ts index 533fd39..e67461a 100644 --- a/packages/protons/test/fixtures/circuit.ts +++ b/packages/protons/test/fixtures/circuit.ts @@ -54,7 +54,7 @@ export namespace CircuitRelay { } export namespace Status { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__StatusValues) } } @@ -74,7 +74,7 @@ export namespace CircuitRelay { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } diff --git a/packages/protons/test/fixtures/daemon.ts b/packages/protons/test/fixtures/daemon.ts index bb2b583..376f4f3 100644 --- a/packages/protons/test/fixtures/daemon.ts +++ b/packages/protons/test/fixtures/daemon.ts @@ -47,7 +47,7 @@ export namespace Request { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } @@ -208,7 +208,7 @@ export namespace Response { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } @@ -809,7 +809,7 @@ export namespace DHTRequest { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } @@ -935,7 +935,7 @@ export namespace DHTResponse { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } @@ -1102,7 +1102,7 @@ export namespace ConnManagerRequest { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } @@ -1264,7 +1264,7 @@ export namespace PSRequest { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } @@ -1535,7 +1535,7 @@ export namespace PeerstoreRequest { } export namespace Type { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__TypeValues) } } diff --git a/packages/protons/test/fixtures/dht.ts b/packages/protons/test/fixtures/dht.ts index df971b4..4dd7698 100644 --- a/packages/protons/test/fixtures/dht.ts +++ b/packages/protons/test/fixtures/dht.ts @@ -128,7 +128,7 @@ export namespace Message { } export namespace MessageType { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__MessageTypeValues) } } @@ -148,7 +148,7 @@ export namespace Message { } export namespace ConnectionType { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__ConnectionTypeValues) } } diff --git a/packages/protons/test/fixtures/optional.ts b/packages/protons/test/fixtures/optional.ts index e78356f..ec75092 100644 --- a/packages/protons/test/fixtures/optional.ts +++ b/packages/protons/test/fixtures/optional.ts @@ -20,7 +20,7 @@ enum __OptionalEnumValues { } export namespace OptionalEnum { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__OptionalEnumValues) } } diff --git a/packages/protons/test/fixtures/singular.ts b/packages/protons/test/fixtures/singular.ts index 81eafa4..7867ec7 100644 --- a/packages/protons/test/fixtures/singular.ts +++ b/packages/protons/test/fixtures/singular.ts @@ -20,7 +20,7 @@ enum __SingularEnumValues { } export namespace SingularEnum { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__SingularEnumValues) } } diff --git a/packages/protons/test/fixtures/test.ts b/packages/protons/test/fixtures/test.ts index 12a951a..4598082 100644 --- a/packages/protons/test/fixtures/test.ts +++ b/packages/protons/test/fixtures/test.ts @@ -18,7 +18,7 @@ enum __AnEnumValues { } export namespace AnEnum { - export const codec = () => { + export const codec = (): Codec => { return enumeration(__AnEnumValues) } } diff --git a/packages/protons/test/index.spec.ts b/packages/protons/test/index.spec.ts index d74b1e4..b9ac8d4 100644 --- a/packages/protons/test/index.spec.ts +++ b/packages/protons/test/index.spec.ts @@ -13,7 +13,7 @@ import Long from 'long' import { Optional, OptionalEnum } from './fixtures/optional.js' import { Singular, SingularEnum } from './fixtures/singular.js' -function longifyBigInts (obj: any) { +function longifyBigInts (obj: any): any { const output = { ...obj } @@ -27,7 +27,7 @@ function longifyBigInts (obj: any) { return output } -function bigintifyLongs (obj: any) { +function bigintifyLongs (obj: any): any { const output = { ...obj } @@ -41,7 +41,7 @@ function bigintifyLongs (obj: any) { return output } -function uint8ArrayifyBytes (obj: any) { +function uint8ArrayifyBytes (obj: any): any { const output = { ...obj } @@ -58,7 +58,7 @@ function uint8ArrayifyBytes (obj: any) { /** * Paper over differences between protons and pbjs output */ -function normalizePbjs (obj: any, target: any) { +function normalizePbjs (obj: any, target: any): any { let output = bigintifyLongs(obj) output = uint8ArrayifyBytes(output) @@ -75,7 +75,7 @@ function normalizePbjs (obj: any, target: any) { /** * Paper over differences between protons and pbjs output */ -function normalizeProtonbufjs (obj: any, target: any) { +function normalizeProtonbufjs (obj: any, target: any): any { let output = bigintifyLongs(obj) output = uint8ArrayifyBytes(output) @@ -100,7 +100,7 @@ interface TestEncodingOptions { * 1. the generated bytes between protons, pbjs and protobuf.js are the same * 2. protons and protobuf.js agree on deserialization */ -function testEncodings (obj: any, protons: any, proto: string, typeName: string, opts: TestEncodingOptions = {}) { +function testEncodings (obj: any, protons: any, proto: string, typeName: string, opts: TestEncodingOptions = {}): void { const pbjsSchema = pbjs.parseSchema(fs.readFileSync(proto, 'utf-8')).compile() const pbjsBuf = pbjsSchema[`encode${typeName}`](longifyBigInts(obj))