Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: remove buffer (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias authored Apr 27, 2020
1 parent e69a1e2 commit 80fb248
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"peer-id": "~0.13.6"
},
"dependencies": {
"buffer-split": "^1.0.0",
"buffer": "^5.6.0",
"err-code": "^2.0.0",
"multihashes": "~0.4.15",
"multihashing-async": "^0.8.0",
Expand Down
2 changes: 1 addition & 1 deletion src/record.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const protons = require('protons')

const { Buffer } = require('buffer')
const pb = protons(require('./record.proto')).Record
const utils = require('./utils')

Expand Down
4 changes: 1 addition & 3 deletions src/selection.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'

const bsplit = require('buffer-split')
const errcode = require('err-code')

/**
* Select the best record out of the given records.
*
Expand All @@ -18,7 +16,7 @@ const bestRecord = (selectors, k, records) => {
throw errcode(new Error(errMsg), 'ERR_NO_RECORDS_RECEIVED')
}

const parts = bsplit(k, Buffer.from('/'))
const parts = k.toString().split('/')

if (parts.length < 3) {
const errMsg = 'Record key does not have a selector function'
Expand Down
4 changes: 1 addition & 3 deletions src/validator.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
'use strict'

const bsplit = require('buffer-split')
const errcode = require('err-code')

/**
* Checks a record and ensures it is still valid.
* It runs the needed validators.
Expand All @@ -14,7 +12,7 @@ const errcode = require('err-code')
*/
const verifyRecord = (validators, record) => {
const key = record.key
const parts = bsplit(key, Buffer.from('/'))
const parts = key.toString().split('/')

if (parts.length < 3) {
// No validator available
Expand Down
2 changes: 1 addition & 1 deletion src/validators/public-key.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const multihashing = require('multihashing-async')
const errcode = require('err-code')

const { Buffer } = require('buffer')
/**
* Validator for publick key records.
* Verifies that the passed in record value is the PublicKey
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/go-key-records.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'

const { Buffer } = require('buffer')
module.exports = {
publicKey: Buffer.from(
'CAASXjBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDjXAQQMal4SB2tSnX6NJIPmC69/BT8A8jc7/gDUZNkEhdhYHvc7k7S4vntV/c92nJGxNdop9fKJyevuNMuXhhHAgMBAAE=',
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/go-record.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict'

const { Buffer } = require('buffer')
// Fixtures generated using gore (https://github.com/motemen/gore)
//
// :import github.com/libp2p/go-libp2p-record
Expand Down
2 changes: 1 addition & 1 deletion test/record.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
const chai = require('chai')
chai.use(require('dirty-chai'))
const expect = chai.expect

const { Buffer } = require('buffer')
const libp2pRecord = require('../src')
const Record = libp2pRecord.Record

Expand Down
2 changes: 1 addition & 1 deletion test/selection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict'

var expect = require('chai').expect

const { Buffer } = require('buffer')
const libp2pRecord = require('../src')
const selection = libp2pRecord.selection

Expand Down
2 changes: 1 addition & 1 deletion test/validator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ chai.use(require('dirty-chai'))
const expect = chai.expect
const crypto = require('libp2p-crypto')
const PeerId = require('peer-id')

const { Buffer } = require('buffer')
const libp2pRecord = require('../src')
const validator = libp2pRecord.validator
const Record = libp2pRecord.Record
Expand Down

0 comments on commit 80fb248

Please sign in to comment.