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
| abstract, boolean, break, byte, case, catch, char, class, const, continue, debugger, | |
| default, delete, do, double, else, enum, export, extends, false, final, finally, | |
| float, for, function, goto, if, implements, import, in, instanceof, int, interface, | |
| long, native, new, null, package, private, protected, public, return, short, static, | |
| super, switch, synchronized, this, throw, throws, transient, true, try, typeof, var, | |
| volatile, void, while, with |
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 stringSplice(source, index, deleteChars, insert) { | |
| insert = insert || ''; | |
| return source.slice(0, index) + insert + source.slice(index + Math.abs(deleteChars)); | |
| } |
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
| // example findFirst('a = b(1, {}, 2)', ['(', '{']) => 5 | |
| function findFirst(source, list, pos) { | |
| var found = -1; | |
| for (var i = 0, len = list.length; i < len; i++) { | |
| var index = source.indexOf(list[i], pos); | |
| if (index >= 0) { | |
| if (found < 0 || index < found) found = index; | |
| } | |
| } | |
| return found; |
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 clone(obj) { | |
| if (Object(obj) !== obj) return obj; | |
| if (typeof obj.toJSON == 'function') { | |
| return obj.toJSON(); | |
| } | |
| var type = toString.call(obj).slice(8, -1); | |
| if (type in CLONE) { | |
| return CLONE[type].call(obj, clone); | |
| } | |
| var copy = {}; |
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
| eval = (function(eval) { return function(code) { return eval(code) } })(eval); | |
| try { | |
| throw null | |
| } catch(app) { | |
| app = function() { console.log('Hello World') } | |
| app.version = '1.2'; | |
| //... all my code here ... | |
| //now all my code has access to app, but eval doesn't | |
| //and my code can execute in global scope (if desired) | |
| console.log(eval('typeof app')) |
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 toJSON(node) { | |
| let propFix = { for: 'htmlFor', class: 'className' }; | |
| let specialGetters = { | |
| style: (node) => node.style.cssText, | |
| }; | |
| let attrDefaultValues = { style: '' }; | |
| let obj = { | |
| nodeType: node.nodeType, | |
| }; | |
| if (node.tagName) { |
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 mysql_escape_string(str) { | |
| return str.replace(/[\0\x08\x09\x1a\n\r"'\\\%]/g, function(ch) { | |
| switch (ch) { | |
| case "\0": | |
| return "\\0"; | |
| case "\x08": | |
| return "\\b"; | |
| case "\x09": | |
| return "\\t"; | |
| case "\x1a": |
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
| //typeof replacement one-liner | |
| var type = (val === null) ? 'null' : Array.isArray(val) ? 'array' : typeof val; |
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
| /*! | |
| * HTML Parser | |
| * Ported from CKEditor 4.2 (f74e558351) | |
| * | |
| */ | |
| /*global require, exports, module, define */ | |
| var HTMLParser; | |
| (function(definition) { | |
| if (typeof exports == 'object' && typeof module == 'object') { | |
| // CommonJS/Node |
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 addEvent(element, eventName, callback) { | |
| if (element.addEventListener) { | |
| element.addEventListener(eventName, callback, false) | |
| } else { | |
| element.attachEvent(eventName, callback, false); | |
| } | |
| } |