Skip to content

Commit

Permalink
Use named imports for fast-json-patch,
Browse files Browse the repository at this point in the history
no to use undocumented default export.
Fixes swagger-api#1460
  • Loading branch information
tomalec committed Aug 8, 2019
1 parent 8b8e026 commit 643ba4a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/specmap/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import jsonPatch from 'fast-json-patch'
import { applyPatch as fastApplyPatch, getValueByPointer} from 'fast-json-patch'
import regenerator from '@babel/runtime-corejs2/regenerator'
import deepExtend from 'deep-extend'
import deepAssign from '@kyleshockey/object-assign-deep'
Expand Down Expand Up @@ -40,7 +40,7 @@ function applyPatch(obj, patch, opts) {
if (patch.op === 'merge') {
const newValue = getInByJsonPath(obj, patch.path)
Object.assign(newValue, patch.value)
jsonPatch.applyPatch(obj, [replace(patch.path, newValue)])
fastApplyPatch(obj, [replace(patch.path, newValue)])
}
else if (patch.op === 'mergeDeep') {
const currentValue = getInByJsonPath(obj, patch.path)
Expand Down Expand Up @@ -98,7 +98,7 @@ function applyPatch(obj, patch, opts) {
return arr
}, [])

jsonPatch.applyPatch(obj, patches)
fastApplyPatch(obj, patches)
}
else if (patch.op === 'replace' && patch.path === '') {
let value = patch.value
Expand All @@ -110,14 +110,14 @@ function applyPatch(obj, patch, opts) {
obj = value
}
else {
jsonPatch.applyPatch(obj, [patch])
fastApplyPatch(obj, [patch])

// Attach metadata to the resulting value.
if (opts.allowMetaPatches && patch.meta && isAdditiveMutation(patch) &&
(Array.isArray(patch.value) || isObject(patch.value))) {
const currentValue = getInByJsonPath(obj, patch.path)
const newValue = Object.assign({}, currentValue, patch.meta)
jsonPatch.applyPatch(obj, [replace(patch.path, newValue)])
fastApplyPatch(obj, [replace(patch.path, newValue)])
}
}

Expand Down Expand Up @@ -356,7 +356,7 @@ function isPatch(patch) {

function getInByJsonPath(obj, jsonPath) {
try {
return jsonPatch.getValueByPointer(obj, jsonPath)
return getValueByPointer(obj, jsonPath)
}
catch (e) {
console.error(e) // eslint-disable-line no-console
Expand Down

0 comments on commit 643ba4a

Please sign in to comment.