This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.get = function(document, pointer) { | |
//Empty pointer references the whole document | |
if(pointer === '') return document; | |
//Split the pointer into reference tokens and unescape | |
var referenceTokens = pointer.slice(1).split('/').map(unescape); | |
//Decent down the object iteratively | |
return referenceTokens.reduce(function(object, token) { |