Skip to content

Commit

Permalink
chore: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
martinheidegger committed Mar 21, 2022
1 parent a742b1e commit e17140b
Show file tree
Hide file tree
Showing 22 changed files with 302 additions and 281 deletions.
23 changes: 12 additions & 11 deletions bench/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
var protobuf = require('../')
var fs = require('fs')
var path = require('path')
var messages = protobuf(fs.readFileSync(path.join(__dirname, 'bench.proto')))
'use strict'
const protobuf = require('../')
const fs = require('fs')
const path = require('path')
const messages = protobuf(fs.readFileSync(path.join(__dirname, 'bench.proto')))

var TIMES = 1000000
const TIMES = 1000000

var then = 0
var diff = 0
let then = 0
let diff = 0

var run = function (name, encode, decode) {
var EXAMPLE = {
const run = function (name, encode, decode) {
const EXAMPLE = {
foo: 'hello',
hello: 42,
payload: Buffer.from('a'),
Expand All @@ -23,8 +24,8 @@ var run = function (name, encode, decode) {
}
}

var EXAMPLE_BUFFER = encode(EXAMPLE)
var i
const EXAMPLE_BUFFER = encode(EXAMPLE)
let i

console.log('Benchmarking %s', name)
console.log(' Running object encoding benchmark...')
Expand Down
19 changes: 10 additions & 9 deletions bin.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env node
var protobuf = require('./')
var fs = require('fs')
'use strict'
const protobuf = require('./')
const fs = require('fs')

var filename = null
var output = null
var watch = false
var encodings = null
let filename = null
let output = null
let watch = false
let encodings = null

// handrolled parser to not introduce minimist as this is used a bunch of prod places
// TODO: if this becomes more complicated / has bugs, move to minimist
for (var i = 2; i < process.argv.length; i++) {
var v = process.argv[i]
var n = v.split('=')[0]
for (let i = 2; i < process.argv.length; i++) {
const v = process.argv[i]
const n = v.split('=')[0]
if (v[0] !== '-') {
filename = v
} else if (n === '--output' || n === '-o' || n === '-wo') {
Expand Down
15 changes: 8 additions & 7 deletions compile-to-js.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var os = require('os')
'use strict'
const os = require('os')

var RESERVED = {
const RESERVED = {
type: true,
message: true,
name: true,
Expand All @@ -16,8 +17,8 @@ function isEncoder (m) {
}

function compile (messages, opts) {
var out = ''
var encodings = opts && opts.encodings
let out = ''
const encodings = opts && opts.encodings

out += '// This file is auto generated by the protocol-buffers compiler' + os.EOL
out += os.EOL
Expand All @@ -43,7 +44,7 @@ function compile (messages, opts) {

if (!safe) return JSON.stringify(map, null, 2).replace(/\n/g, os.EOL) + os.EOL

var out = '{' + os.EOL
let out = '{' + os.EOL

keys.forEach(function (k, i) {
out += spaces + ' ' + k + ': ' + map[k] + (i < keys.length - 1 ? ',' : '') + os.EOL
Expand All @@ -53,12 +54,12 @@ function compile (messages, opts) {
}

function visit (messages, exports, spaces) {
var encoders = Object.keys(messages).filter(function (name) {
const encoders = Object.keys(messages).filter(function (name) {
if (RESERVED[name]) return false
return isEncoder(messages[name])
})

var enums = Object.keys(messages).filter(function (name) {
const enums = Object.keys(messages).filter(function (name) {
if (RESERVED[name]) return false
return !isEncoder(messages[name])
})
Expand Down

0 comments on commit e17140b

Please sign in to comment.