This file contains 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
(function (document) { | |
'use strict'; | |
/* | |
* LODASH in-Browser JSON transformer | |
* Use this in a bookmarket (save its contents in a bookmark) and whenever you open a JSON response (e.g. https://www.reddit.com/.json) | |
* you can use it to test lodash methods against the data. | |
* Lodash is exposed on window as _ and "json" global variable contains the data within the browser window. | |
* | |
* Copy the line below and save it as the url of a new bookmark (it's the same code as below but minified for bookmark use): | |
* javascript:!function(e){"use%20strict";function%20t(){s=JSON.parse(j.innerText||j.textContent),y.src=p,y.onload=n,e.head.appendChild(y)}function%20n(){window.json=JSON.parse(JSON.stringify(s)),i(window.json),m.oninput=o,e.body.appendChild(m),e.body.appendChild(x)}function%20o(e){var%20t,n=e||event,o=n.target||n.srcElement;return%20o.value?(t=a(o.value),void(t&&"object"==typeof%20t?(r(o,"success"),i(t)):r(o,"error"))):(i(s),void%20r(o,"success"))}function%20i(e){j.innerText?j.innerText=JSO |
This file contains 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
// Here is a JSFiddle with a concrete example: https://jsfiddle.net/SeanJM/rg3ftcgk/1/ | |
// This is one of Sean's most leveraged functions, which he uses to keep my code nice and modular | |
function fnChain(target, source, args) { | |
'use strict'; | |
var objProto = Object.prototype, hasOwn, chain, k; | |
if (objProto.toString.apply(args) !== '[object Array]') { | |
throw new TypeError('Invalid argument for "fnChain": The 3rd argument must be an array of arguments.'); | |
} | |
hasOwn = objProto.hasOwnProperty; | |
chain = function chain(k) { |