Skip to content

Commit

Permalink
feat(*): Add edge compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke committed Jan 9, 2020
1 parent aea8fa7 commit 07cb6f3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .airtap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ browsers:
version: latest
- name: safari
version: latest
# - name: microsoftedge
# version: latest
- name: microsoftedge
version: latest
- name: android
version: '6.0'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,6 @@ typings/

# Serverless directories
.serverless

# Ignore IDEA
.idea/
17 changes: 5 additions & 12 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,15 @@ DB.prototype._put = function (key, value, options, callback) {
}

DB.prototype._get = function (key, options, callback) {
this.db.get(key, { ...options, asBuffer: false }, (err, cipher) => {
this.db.get(key, Object.assign({}, options, { asBuffer: false }), (err, cipher) => {
if (err) {
return callback(err)
}
this.codec
.decrypt(cipher)
.then(function (value) {
const checkedValue = emptyStringWhenNull(value)
callback(
null,
options.asBuffer ? Buffer.from(String(checkedValue)) : checkedValue
)
callback(null, options.asBuffer ? Buffer.from(String(checkedValue)) : checkedValue)
})
.catch(callback)
})
Expand Down Expand Up @@ -108,7 +105,7 @@ function Iterator (db, options) {
this.keys = options.keys
this.values = options.values
this.options = options
this.it = db.db.iterator({ ...this.options, valueAsBuffer: false })
this.it = db.db.iterator(Object.assign({}, this.options, { valueAsBuffer: false }))
}

inherits(Iterator, AbstractIterator)
Expand All @@ -124,11 +121,7 @@ Iterator.prototype._next = function (callback) {
this.codec
.decrypt(cipher)
.then(value => {
callback(
null,
key,
this.options.valueAsBuffer ? Buffer.from(String(value)) : value
)
callback(null, key, this.options.valueAsBuffer ? Buffer.from(String(value)) : value)
})
.catch(callback)
})
Expand All @@ -144,6 +137,6 @@ function emptyStringWhenNull (value) {

function encryptOperationValue (codec, operation) {
return codec.encrypt(operation.value).then(function (cipher) {
return { ...operation, value: cipher }
return Object.assign({}, operation, { value: cipher })
})
}

0 comments on commit 07cb6f3

Please sign in to comment.