Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
var JSON8Pointer = require('json8-pointer')
var parse = JSON8Pointer.parse
var walk = JSON8Pointer.walk
var JSON8 = require('json8')
var clone = JSON8.clone
var equal = JSON8.equal
var get = require('./extras').get
/**
* Add the value to the specified JSON Pointer location
* http://tools.ietf.org/html/rfc6902#section-4.1
*
* @param {Object|Array} doc - JSON document to set the value to
* @param {Path} path - JSON Pointer string or tokens path
* @param {Any} value - value to add
* @return {Array} - [document, replaced value]
*/
var add = function(doc, path, value) {
var tokens = parse(path)
// replaces the document