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
// A function to return an array of indexes for a matching string. | |
// Usage : indexesOf('this, this this', 'this'); | |
// Usage : indexesOf('this, this this', /t[a-z]{3}/); | |
// -> [{"index":0,"length":4,"match":"this"}, | |
// {"index":6,"length":4,"match":"this"}, | |
// {"index":11,"length":4,"match":"this"}] | |
// | |
// The 'and' method: | |
// Usage : indexesOf('this, this this', /t[a-z]{3}/).and(/i/); | |
// -> [{"index":0,"length":4,"match":"this"}, |
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
// A function which which allows you to apply a list of functions (supplied as arguments) to a value. | |
// | |
// Usage: pipe(functions...)(value) | |
// | |
// Example: var getFirstWordLetter = pipe(getFirstWord, getFirstLetter); | |
// getFirstWordLetter('Sean MacIsaac') | |
// -> 'S' | |
function pipe () { | |
var functionList = [].slice.call(arguments); |
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
function getNodePath (node) { | |
var path = []; | |
while (node) { | |
path.unshift(toSelector(node)); | |
if (node === document.body || node.id.length > 0) { | |
return path.join(' '); | |
} | |
node = node.parentNode; | |
} | |
return path.join(' '); |
NewerOlder