id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
12,200
que-etc/resize-observer-polyfill
src/utils/geometry.js
getHTMLElementContentRect
function getHTMLElementContentRect(target) { // Client width & height properties can't be // used exclusively as they provide rounded values. const {clientWidth, clientHeight} = target; // By this condition we can catch all non-replaced inline, hidden and // detached elements. Though elements with ...
javascript
function getHTMLElementContentRect(target) { // Client width & height properties can't be // used exclusively as they provide rounded values. const {clientWidth, clientHeight} = target; // By this condition we can catch all non-replaced inline, hidden and // detached elements. Though elements with ...
[ "function", "getHTMLElementContentRect", "(", "target", ")", "{", "// Client width & height properties can't be", "// used exclusively as they provide rounded values.", "const", "{", "clientWidth", ",", "clientHeight", "}", "=", "target", ";", "// By this condition we can catch all...
Calculates content rectangle of provided HTMLElement. @param {HTMLElement} target - Element for which to calculate the content rectangle. @returns {DOMRectInit}
[ "Calculates", "content", "rectangle", "of", "provided", "HTMLElement", "." ]
4a148452494a155656e4d04b9732b5914896b2e0
https://github.com/que-etc/resize-observer-polyfill/blob/4a148452494a155656e4d04b9732b5914896b2e0/src/utils/geometry.js#L71-L145
12,201
jhipster/prettier-java
packages/java-parser/scripts/unicode.js
pushInUnicode
function pushInUnicode(cat, elt) { if (!unicode.hasOwnProperty(cat)) { unicode[cat] = { unicode: [], ranges: [] }; } if (Array.isArray(elt)) { unicode[cat].ranges.push(elt); } else { unicode[cat].unicode.push(elt); } }
javascript
function pushInUnicode(cat, elt) { if (!unicode.hasOwnProperty(cat)) { unicode[cat] = { unicode: [], ranges: [] }; } if (Array.isArray(elt)) { unicode[cat].ranges.push(elt); } else { unicode[cat].unicode.push(elt); } }
[ "function", "pushInUnicode", "(", "cat", ",", "elt", ")", "{", "if", "(", "!", "unicode", ".", "hasOwnProperty", "(", "cat", ")", ")", "{", "unicode", "[", "cat", "]", "=", "{", "unicode", ":", "[", "]", ",", "ranges", ":", "[", "]", "}", ";", ...
Function that pushes in an object an attribute to store the characters
[ "Function", "that", "pushes", "in", "an", "object", "an", "attribute", "to", "store", "the", "characters" ]
3555a0c6e53697f0026bf8bf56403bb6b7719b17
https://github.com/jhipster/prettier-java/blob/3555a0c6e53697f0026bf8bf56403bb6b7719b17/packages/java-parser/scripts/unicode.js#L35-L48
12,202
jhipster/prettier-java
packages/java-parser/scripts/unicode.js
generateFile
function generateFile() { let data = ` /*File generated with ../scripts/unicode.js using ../resources/Unicode/UnicodeData.txt. * As Java Identifiers may contains unicodes letters, this file defines two sets of unicode * characters, firstIdentChar used to help to determine if a character can be the first letter ...
javascript
function generateFile() { let data = ` /*File generated with ../scripts/unicode.js using ../resources/Unicode/UnicodeData.txt. * As Java Identifiers may contains unicodes letters, this file defines two sets of unicode * characters, firstIdentChar used to help to determine if a character can be the first letter ...
[ "function", "generateFile", "(", ")", "{", "let", "data", "=", "`", "`", ";", "firstIdentCharCategories", ".", "forEach", "(", "el", "=>", "{", "unicode", "[", "el", "]", ".", "unicode", ".", "forEach", "(", "value", "=>", "{", "data", "+=", "`", "${...
Generating a unicodesets.js file so that we don't have to reparse the file each time the parser is called.
[ "Generating", "a", "unicodesets", ".", "js", "file", "so", "that", "we", "don", "t", "have", "to", "reparse", "the", "file", "each", "time", "the", "parser", "is", "called", "." ]
3555a0c6e53697f0026bf8bf56403bb6b7719b17
https://github.com/jhipster/prettier-java/blob/3555a0c6e53697f0026bf8bf56403bb6b7719b17/packages/java-parser/scripts/unicode.js#L151-L237
12,203
stampit-org/stampit
src/stampit.js
standardiseDescriptor
function standardiseDescriptor(descr) { var4 = {}; var4[_methods] = descr[_methods] || _undefined; var1 = descr[_properties]; var2 = descr.props; var4[_properties] = isObject(var1 || var2) ? assign({}, var2, var1) : _undefined; var4[_initializers] = extractUniqueFunctions(descr.init, descr[_i...
javascript
function standardiseDescriptor(descr) { var4 = {}; var4[_methods] = descr[_methods] || _undefined; var1 = descr[_properties]; var2 = descr.props; var4[_properties] = isObject(var1 || var2) ? assign({}, var2, var1) : _undefined; var4[_initializers] = extractUniqueFunctions(descr.init, descr[_i...
[ "function", "standardiseDescriptor", "(", "descr", ")", "{", "var4", "=", "{", "}", ";", "var4", "[", "_methods", "]", "=", "descr", "[", "_methods", "]", "||", "_undefined", ";", "var1", "=", "descr", "[", "_properties", "]", ";", "var2", "=", "descr"...
Converts stampit extended descriptor to a standard one. @param {Object|*} descr methods properties props initializers init deepProperties deepProps propertyDescriptors staticProperties statics staticDeepProperties deepStatics staticPropertyDescriptors configuration conf deepConfiguration deepConf composers @returns {De...
[ "Converts", "stampit", "extended", "descriptor", "to", "a", "standard", "one", "." ]
11b1aaad02e5942450366b97f1881346b1171685
https://github.com/stampit-org/stampit/blob/11b1aaad02e5942450366b97f1881346b1171685/src/stampit.js#L133-L173
12,204
ionic-team/ionic-app-scripts
bin/ion-dev.js
function(msg) { var status = 'success'; if (msg.type === 'started') { status = 'active'; this.buildingNotification(true); } else { if (msg.data.reloadApp) { this.reloadApp(); return; } status = msg.data.diagnosticsHtml ? 'error' : 'success'; this.buil...
javascript
function(msg) { var status = 'success'; if (msg.type === 'started') { status = 'active'; this.buildingNotification(true); } else { if (msg.data.reloadApp) { this.reloadApp(); return; } status = msg.data.diagnosticsHtml ? 'error' : 'success'; this.buil...
[ "function", "(", "msg", ")", "{", "var", "status", "=", "'success'", ";", "if", "(", "msg", ".", "type", "===", "'started'", ")", "{", "status", "=", "'active'", ";", "this", ".", "buildingNotification", "(", "true", ")", ";", "}", "else", "{", "if",...
Process a build update message and display something to the friendly user.
[ "Process", "a", "build", "update", "message", "and", "display", "something", "to", "the", "friendly", "user", "." ]
5d7ca3825e1aada6a9457a98572d4e86d5e4b0e6
https://github.com/ionic-team/ionic-app-scripts/blob/5d7ca3825e1aada6a9457a98572d4e86d5e4b0e6/bin/ion-dev.js#L183-L239
12,205
ionic-team/ionic-app-scripts
lab/static/js/lab.js
bindToggles
function bindToggles() { // Watch for changes on the checkboxes in the device dropdown var iphone = $('#device-iphone'); var android = $('#device-android'); var windows = $('#device-windows'); var devices = [iphone, android, windows]; for(var i in devices) { devices[i].addEventListener('change', functi...
javascript
function bindToggles() { // Watch for changes on the checkboxes in the device dropdown var iphone = $('#device-iphone'); var android = $('#device-android'); var windows = $('#device-windows'); var devices = [iphone, android, windows]; for(var i in devices) { devices[i].addEventListener('change', functi...
[ "function", "bindToggles", "(", ")", "{", "// Watch for changes on the checkboxes in the device dropdown", "var", "iphone", "=", "$", "(", "'#device-iphone'", ")", ";", "var", "android", "=", "$", "(", "'#device-android'", ")", ";", "var", "windows", "=", "$", "("...
Bind the dropdown platform toggles
[ "Bind", "the", "dropdown", "platform", "toggles" ]
5d7ca3825e1aada6a9457a98572d4e86d5e4b0e6
https://github.com/ionic-team/ionic-app-scripts/blob/5d7ca3825e1aada6a9457a98572d4e86d5e4b0e6/lab/static/js/lab.js#L96-L112
12,206
ionic-team/ionic-app-scripts
lab/static/js/lab.js
showDevice
function showDevice(device, isShowing) { $('#device-' + device).checked = isShowing; var rendered = $('#' + device); if(!rendered) { var template = $('#' + device + '-frame-template'); var clone = document.importNode(template, true); $('preview').appendChild(clone.content); //check for extra para...
javascript
function showDevice(device, isShowing) { $('#device-' + device).checked = isShowing; var rendered = $('#' + device); if(!rendered) { var template = $('#' + device + '-frame-template'); var clone = document.importNode(template, true); $('preview').appendChild(clone.content); //check for extra para...
[ "function", "showDevice", "(", "device", ",", "isShowing", ")", "{", "$", "(", "'#device-'", "+", "device", ")", ".", "checked", "=", "isShowing", ";", "var", "rendered", "=", "$", "(", "'#'", "+", "device", ")", ";", "if", "(", "!", "rendered", ")",...
Show one of the devices
[ "Show", "one", "of", "the", "devices" ]
5d7ca3825e1aada6a9457a98572d4e86d5e4b0e6
https://github.com/ionic-team/ionic-app-scripts/blob/5d7ca3825e1aada6a9457a98572d4e86d5e4b0e6/lab/static/js/lab.js#L115-L133
12,207
angular-slider/angularjs-slider
demo/lib/ui-bootstrap-tpls.js
toggleTopWindowClass
function toggleTopWindowClass(toggleSwitch) { var modalWindow; if (openedWindows.length() > 0) { modalWindow = openedWindows.top().value; modalWindow.modalDomEl.toggleClass(modalWindow.windowTopClass || '', toggleSwitch); } }
javascript
function toggleTopWindowClass(toggleSwitch) { var modalWindow; if (openedWindows.length() > 0) { modalWindow = openedWindows.top().value; modalWindow.modalDomEl.toggleClass(modalWindow.windowTopClass || '', toggleSwitch); } }
[ "function", "toggleTopWindowClass", "(", "toggleSwitch", ")", "{", "var", "modalWindow", ";", "if", "(", "openedWindows", ".", "length", "(", ")", ">", "0", ")", "{", "modalWindow", "=", "openedWindows", ".", "top", "(", ")", ".", "value", ";", "modalWindo...
Add or remove "windowTopClass" from the top window in the stack
[ "Add", "or", "remove", "windowTopClass", "from", "the", "top", "window", "in", "the", "stack" ]
28bf4e71c5c8e87bce4517974d2c65e6d8a5c295
https://github.com/angular-slider/angularjs-slider/blob/28bf4e71c5c8e87bce4517974d2c65e6d8a5c295/demo/lib/ui-bootstrap-tpls.js#L3786-L3793
12,208
angular-slider/angularjs-slider
demo/lib/ui-bootstrap-tpls.js
prepareTooltip
function prepareTooltip() { ttScope.title = attrs[prefix + 'Title']; if (contentParse) { ttScope.content = contentParse(scope); } else { ttScope.content = attrs[ttType]; } ttScope.popupClass = attrs[prefix + 'Class'];...
javascript
function prepareTooltip() { ttScope.title = attrs[prefix + 'Title']; if (contentParse) { ttScope.content = contentParse(scope); } else { ttScope.content = attrs[ttType]; } ttScope.popupClass = attrs[prefix + 'Class'];...
[ "function", "prepareTooltip", "(", ")", "{", "ttScope", ".", "title", "=", "attrs", "[", "prefix", "+", "'Title'", "]", ";", "if", "(", "contentParse", ")", "{", "ttScope", ".", "content", "=", "contentParse", "(", "scope", ")", ";", "}", "else", "{", ...
Set the inital scope values. Once the tooltip is created, the observers will be added to keep things in synch.
[ "Set", "the", "inital", "scope", "values", ".", "Once", "the", "tooltip", "is", "created", "the", "observers", "will", "be", "added", "to", "keep", "things", "in", "synch", "." ]
28bf4e71c5c8e87bce4517974d2c65e6d8a5c295
https://github.com/angular-slider/angularjs-slider/blob/28bf4e71c5c8e87bce4517974d2c65e6d8a5c295/demo/lib/ui-bootstrap-tpls.js#L5204-L5219
12,209
angular-slider/angularjs-slider
demo/lib/ui-bootstrap-tpls.js
recalculatePosition
function recalculatePosition() { scope.position = appendToBody ? $position.offset(element) : $position.position(element); scope.position.top += element.prop('offsetHeight'); }
javascript
function recalculatePosition() { scope.position = appendToBody ? $position.offset(element) : $position.position(element); scope.position.top += element.prop('offsetHeight'); }
[ "function", "recalculatePosition", "(", ")", "{", "scope", ".", "position", "=", "appendToBody", "?", "$position", ".", "offset", "(", "element", ")", ":", "$position", ".", "position", "(", "element", ")", ";", "scope", ".", "position", ".", "top", "+=", ...
recalculate actual position and set new values to scope after digest loop is popup in right position
[ "recalculate", "actual", "position", "and", "set", "new", "values", "to", "scope", "after", "digest", "loop", "is", "popup", "in", "right", "position" ]
28bf4e71c5c8e87bce4517974d2c65e6d8a5c295
https://github.com/angular-slider/angularjs-slider/blob/28bf4e71c5c8e87bce4517974d2c65e6d8a5c295/demo/lib/ui-bootstrap-tpls.js#L7312-L7315
12,210
angular-slider/angularjs-slider
demo/lib/ui-bootstrap-tpls.js
function(evt) { // Issue #3973 // Firefox treats right click as a click on document if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) { resetMatches(); if (!$rootScope.$$phase) { scope.$digest(); } } }
javascript
function(evt) { // Issue #3973 // Firefox treats right click as a click on document if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) { resetMatches(); if (!$rootScope.$$phase) { scope.$digest(); } } }
[ "function", "(", "evt", ")", "{", "// Issue #3973", "// Firefox treats right click as a click on document", "if", "(", "element", "[", "0", "]", "!==", "evt", ".", "target", "&&", "evt", ".", "which", "!==", "3", "&&", "scope", ".", "matches", ".", "length", ...
Keep reference to click handler to unbind it.
[ "Keep", "reference", "to", "click", "handler", "to", "unbind", "it", "." ]
28bf4e71c5c8e87bce4517974d2c65e6d8a5c295
https://github.com/angular-slider/angularjs-slider/blob/28bf4e71c5c8e87bce4517974d2c65e6d8a5c295/demo/lib/ui-bootstrap-tpls.js#L7410-L7419
12,211
icebob/fastest-validator
lib/validator.js
Validator
function Validator(opts) { this.opts = { messages: deepExtend({}, defaultMessages) }; if (opts) deepExtend(this.opts, opts); this.messages = this.opts.messages; this.messageKeys = Object.keys(this.messages); // Load rules this.rules = loadRules(); this.cache = new Map(); }
javascript
function Validator(opts) { this.opts = { messages: deepExtend({}, defaultMessages) }; if (opts) deepExtend(this.opts, opts); this.messages = this.opts.messages; this.messageKeys = Object.keys(this.messages); // Load rules this.rules = loadRules(); this.cache = new Map(); }
[ "function", "Validator", "(", "opts", ")", "{", "this", ".", "opts", "=", "{", "messages", ":", "deepExtend", "(", "{", "}", ",", "defaultMessages", ")", "}", ";", "if", "(", "opts", ")", "deepExtend", "(", "this", ".", "opts", ",", "opts", ")", ";...
Validator class constructor @param {Object} opts
[ "Validator", "class", "constructor" ]
a5f2b056bd9d92037b90dd214d0aa2a43073bd6b
https://github.com/icebob/fastest-validator/blob/a5f2b056bd9d92037b90dd214d0aa2a43073bd6b/lib/validator.js#L59-L73
12,212
icebob/fastest-validator
lib/helpers/flatten.js
flatten
function flatten(array, target) { const result = target || []; for (let i = 0; i < array.length; ++i) { if (Array.isArray(array[i])) { flatten(array[i], result); } else { result.push(array[i]); } } return result; }
javascript
function flatten(array, target) { const result = target || []; for (let i = 0; i < array.length; ++i) { if (Array.isArray(array[i])) { flatten(array[i], result); } else { result.push(array[i]); } } return result; }
[ "function", "flatten", "(", "array", ",", "target", ")", "{", "const", "result", "=", "target", "||", "[", "]", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "array", ".", "length", ";", "++", "i", ")", "{", "if", "(", "Array", ".", "...
Flatten an array @param {Array} array @param {Array} target @returns Array flattened array
[ "Flatten", "an", "array" ]
a5f2b056bd9d92037b90dd214d0aa2a43073bd6b
https://github.com/icebob/fastest-validator/blob/a5f2b056bd9d92037b90dd214d0aa2a43073bd6b/lib/helpers/flatten.js#L9-L22
12,213
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { var $this = $(this); //Save state on change $this.on("change", function() { var $this = $(this); if (typeof($this.treegrid('getSetting', 'onChange')) === "function") { $this.treegrid('getSetting', 'onChange').appl...
javascript
function() { var $this = $(this); //Save state on change $this.on("change", function() { var $this = $(this); if (typeof($this.treegrid('getSetting', 'onChange')) === "function") { $this.treegrid('getSetting', 'onChange').appl...
[ "function", "(", ")", "{", "var", "$this", "=", "$", "(", "this", ")", ";", "//Save state on change\r", "$this", ".", "on", "(", "\"change\"", ",", "function", "(", ")", "{", "var", "$this", "=", "$", "(", "this", ")", ";", "if", "(", "typeof", "("...
Initialize events from settings @returns {Node}
[ "Initialize", "events", "from", "settings" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L80-L106
12,214
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { var $this = $(this); var cell = $this.find('td').get($this.treegrid('getSetting', 'treeColumn')); var tpl = $this.treegrid('getSetting', 'expanderTemplate'); var expander = $this.treegrid('getSetting', 'getExpander').apply(this); if (expander...
javascript
function() { var $this = $(this); var cell = $this.find('td').get($this.treegrid('getSetting', 'treeColumn')); var tpl = $this.treegrid('getSetting', 'expanderTemplate'); var expander = $this.treegrid('getSetting', 'getExpander').apply(this); if (expander...
[ "function", "(", ")", "{", "var", "$this", "=", "$", "(", "this", ")", ";", "var", "cell", "=", "$this", ".", "find", "(", "'td'", ")", ".", "get", "(", "$this", ".", "treegrid", "(", "'getSetting'", ",", "'treeColumn'", ")", ")", ";", "var", "tp...
Initialize expander for node @returns {Node}
[ "Initialize", "expander", "for", "node" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L112-L124
12,215
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { var $this = $(this); $this.find('.treegrid-indent').remove(); var tpl = $this.treegrid('getSetting', 'indentTemplate'); var expander = $this.find('.treegrid-expander'); var depth = $this.treegrid('getDepth'); for (var i = 0; i < ...
javascript
function() { var $this = $(this); $this.find('.treegrid-indent').remove(); var tpl = $this.treegrid('getSetting', 'indentTemplate'); var expander = $this.find('.treegrid-expander'); var depth = $this.treegrid('getDepth'); for (var i = 0; i < ...
[ "function", "(", ")", "{", "var", "$this", "=", "$", "(", "this", ")", ";", "$this", ".", "find", "(", "'.treegrid-indent'", ")", ".", "remove", "(", ")", ";", "var", "tpl", "=", "$this", ".", "treegrid", "(", "'getSetting'", ",", "'indentTemplate'", ...
Initialize indent for node @returns {Node}
[ "Initialize", "indent", "for", "node" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L130-L140
12,216
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { var tree = $(this).treegrid('getTreeContainer'); if (tree.data('first_init') === undefined) { tree.data('first_init', $.cookie(tree.treegrid('getSetting', 'saveStateName')) === undefined); } return tree.data('first_init'); }
javascript
function() { var tree = $(this).treegrid('getTreeContainer'); if (tree.data('first_init') === undefined) { tree.data('first_init', $.cookie(tree.treegrid('getSetting', 'saveStateName')) === undefined); } return tree.data('first_init'); }
[ "function", "(", ")", "{", "var", "tree", "=", "$", "(", "this", ")", ".", "treegrid", "(", "'getTreeContainer'", ")", ";", "if", "(", "tree", ".", "data", "(", "'first_init'", ")", "===", "undefined", ")", "{", "tree", ".", "data", "(", "'first_init...
Return true if this tree was never been initialised @returns {Boolean}
[ "Return", "true", "if", "this", "tree", "was", "never", "been", "initialised" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L164-L170
12,217
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { var $this = $(this); if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { var stateArrayString = $.cookie($this.treegrid('getSetting', 'saveStateName')) || ''; var stateArray = (stateArrayString === '' ? [] : stateArrayString.spli...
javascript
function() { var $this = $(this); if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { var stateArrayString = $.cookie($this.treegrid('getSetting', 'saveStateName')) || ''; var stateArray = (stateArrayString === '' ? [] : stateArrayString.spli...
[ "function", "(", ")", "{", "var", "$this", "=", "$", "(", "this", ")", ";", "if", "(", "$this", ".", "treegrid", "(", "'getSetting'", ",", "'saveStateMethod'", ")", "===", "'cookie'", ")", "{", "var", "stateArrayString", "=", "$", ".", "cookie", "(", ...
Save state of current node @returns {Node}
[ "Save", "state", "of", "current", "node" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L176-L196
12,218
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { var $this = $(this); if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { var stateArray = $.cookie($this.treegrid('getSetting', 'saveStateName')).split(','); if ($.inArray($this.treegrid('getNodeId'), stateArray) !== -1) { ...
javascript
function() { var $this = $(this); if ($this.treegrid('getSetting', 'saveStateMethod') === 'cookie') { var stateArray = $.cookie($this.treegrid('getSetting', 'saveStateName')).split(','); if ($.inArray($this.treegrid('getNodeId'), stateArray) !== -1) { ...
[ "function", "(", ")", "{", "var", "$this", "=", "$", "(", "this", ")", ";", "if", "(", "$this", ".", "treegrid", "(", "'getSetting'", ",", "'saveStateMethod'", ")", "===", "'cookie'", ")", "{", "var", "stateArray", "=", "$", ".", "cookie", "(", "$thi...
Restore state of current node. @returns {Node}
[ "Restore", "state", "of", "current", "node", "." ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L202-L214
12,219
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { if ($(this).treegrid('isNode')) { var parentNode = $(this).treegrid('getParentNode'); if (parentNode === null) { if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').last().treegrid('getNodeId')) { ...
javascript
function() { if ($(this).treegrid('isNode')) { var parentNode = $(this).treegrid('getParentNode'); if (parentNode === null) { if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').last().treegrid('getNodeId')) { ...
[ "function", "(", ")", "{", "if", "(", "$", "(", "this", ")", ".", "treegrid", "(", "'isNode'", ")", ")", "{", "var", "parentNode", "=", "$", "(", "this", ")", ".", "treegrid", "(", "'getParentNode'", ")", ";", "if", "(", "parentNode", "===", "null"...
Method return true if node last in branch @returns {Boolean}
[ "Method", "return", "true", "if", "node", "last", "in", "branch" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L351-L365
12,220
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { if ($(this).treegrid('isNode')) { var parentNode = $(this).treegrid('getParentNode'); if (parentNode === null) { if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').first().treegrid('getNodeId')) { ...
javascript
function() { if ($(this).treegrid('isNode')) { var parentNode = $(this).treegrid('getParentNode'); if (parentNode === null) { if ($(this).treegrid('getNodeId') === $(this).treegrid('getRootNodes').first().treegrid('getNodeId')) { ...
[ "function", "(", ")", "{", "if", "(", "$", "(", "this", ")", ".", "treegrid", "(", "'isNode'", ")", ")", "{", "var", "parentNode", "=", "$", "(", "this", ")", ".", "treegrid", "(", "'getParentNode'", ")", ";", "if", "(", "parentNode", "===", "null"...
Method return true if node first in branch @returns {Boolean}
[ "Method", "return", "true", "if", "node", "first", "in", "branch" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L371-L385
12,221
maxazan/jquery-treegrid
js/jquery.treegrid.js
function() { return $(this).each(function() { var $this = $(this); var expander = $this.treegrid('getSetting', 'getExpander').apply(this); if (expander) { if (!$this.treegrid('isCollapsed')) { expander.remove...
javascript
function() { return $(this).each(function() { var $this = $(this); var expander = $this.treegrid('getSetting', 'getExpander').apply(this); if (expander) { if (!$this.treegrid('isCollapsed')) { expander.remove...
[ "function", "(", ")", "{", "return", "$", "(", "this", ")", ".", "each", "(", "function", "(", ")", "{", "var", "$this", "=", "$", "(", "this", ")", ";", "var", "expander", "=", "$this", ".", "treegrid", "(", "'getSetting'", ",", "'getExpander'", "...
Rendering expander depends on node state @returns {Node}
[ "Rendering", "expander", "depends", "on", "node", "state" ]
447d66237275cd52ff4c50624920a221caa41ec7
https://github.com/maxazan/jquery-treegrid/blob/447d66237275cd52ff4c50624920a221caa41ec7/js/jquery.treegrid.js#L533-L551
12,222
slackapi/node-slack-interactive-messages
src/adapter.js
formatMatchingConstraints
function formatMatchingConstraints(matchingConstraints) { let ret = {}; if (typeof matchingConstraints === 'undefined' || matchingConstraints === null) { throw new TypeError('Constraints cannot be undefined or null'); } if (!isPlainObject(matchingConstraints)) { ret.callbackId = matchingConstraints; }...
javascript
function formatMatchingConstraints(matchingConstraints) { let ret = {}; if (typeof matchingConstraints === 'undefined' || matchingConstraints === null) { throw new TypeError('Constraints cannot be undefined or null'); } if (!isPlainObject(matchingConstraints)) { ret.callbackId = matchingConstraints; }...
[ "function", "formatMatchingConstraints", "(", "matchingConstraints", ")", "{", "let", "ret", "=", "{", "}", ";", "if", "(", "typeof", "matchingConstraints", "===", "'undefined'", "||", "matchingConstraints", "===", "null", ")", "{", "throw", "new", "TypeError", ...
Transforms various forms of matching constraints to a single standard object shape @param {string|RegExp|Object} matchingConstraints - the various forms of matching constraints accepted @returns {Object} - an object where each matching constraint is a property @private
[ "Transforms", "various", "forms", "of", "matching", "constraints", "to", "a", "single", "standard", "object", "shape" ]
0982098e1cd5356f7fde9f5b82a4c7eb9980f39f
https://github.com/slackapi/node-slack-interactive-messages/blob/0982098e1cd5356f7fde9f5b82a4c7eb9980f39f/src/adapter.js#L28-L39
12,223
slackapi/node-slack-interactive-messages
src/adapter.js
validateConstraints
function validateConstraints(matchingConstraints) { if (matchingConstraints.callbackId && !(isString(matchingConstraints.callbackId) || isRegExp(matchingConstraints.callbackId))) { return new TypeError('Callback ID must be a string or RegExp'); } if (matchingConstraints.blockId && !(isString(matchi...
javascript
function validateConstraints(matchingConstraints) { if (matchingConstraints.callbackId && !(isString(matchingConstraints.callbackId) || isRegExp(matchingConstraints.callbackId))) { return new TypeError('Callback ID must be a string or RegExp'); } if (matchingConstraints.blockId && !(isString(matchi...
[ "function", "validateConstraints", "(", "matchingConstraints", ")", "{", "if", "(", "matchingConstraints", ".", "callbackId", "&&", "!", "(", "isString", "(", "matchingConstraints", ".", "callbackId", ")", "||", "isRegExp", "(", "matchingConstraints", ".", "callback...
Validates general properties of a matching constraints object @param {Object} matchingConstraints - object describing the constraints on a callback @returns {Error|false} - a false value represents successful validation, otherwise an error to describe why validation failed. @private
[ "Validates", "general", "properties", "of", "a", "matching", "constraints", "object" ]
0982098e1cd5356f7fde9f5b82a4c7eb9980f39f
https://github.com/slackapi/node-slack-interactive-messages/blob/0982098e1cd5356f7fde9f5b82a4c7eb9980f39f/src/adapter.js#L48-L65
12,224
slackapi/node-slack-interactive-messages
src/adapter.js
validateOptionsConstraints
function validateOptionsConstraints(optionsConstraints) { if (optionsConstraints.within && !(optionsConstraints.within === 'interactive_message' || optionsConstraints.within === 'block_actions' || optionsConstraints.within === 'dialog') ) { return new TypeError('Within must be \'block_actions\',...
javascript
function validateOptionsConstraints(optionsConstraints) { if (optionsConstraints.within && !(optionsConstraints.within === 'interactive_message' || optionsConstraints.within === 'block_actions' || optionsConstraints.within === 'dialog') ) { return new TypeError('Within must be \'block_actions\',...
[ "function", "validateOptionsConstraints", "(", "optionsConstraints", ")", "{", "if", "(", "optionsConstraints", ".", "within", "&&", "!", "(", "optionsConstraints", ".", "within", "===", "'interactive_message'", "||", "optionsConstraints", ".", "within", "===", "'bloc...
Validates properties of a matching constraints object specific to registering an options request @param {Object} matchingConstraints - object describing the constraints on a callback @returns {Error|false} - a false value represents successful validation, otherwise an error to describe why validation failed. @private
[ "Validates", "properties", "of", "a", "matching", "constraints", "object", "specific", "to", "registering", "an", "options", "request" ]
0982098e1cd5356f7fde9f5b82a4c7eb9980f39f
https://github.com/slackapi/node-slack-interactive-messages/blob/0982098e1cd5356f7fde9f5b82a4c7eb9980f39f/src/adapter.js#L74-L85
12,225
slackapi/node-slack-interactive-messages
examples/express-all-interactions/server.js
slackSlashCommand
function slackSlashCommand(req, res, next) { if (req.body.command === '/interactive-example') { const type = req.body.text.split(' ')[0]; if (type === 'button') { res.json(interactiveButtons); } else if (type === 'menu') { res.json(interactiveMenu); } else if (type === 'dialog') { re...
javascript
function slackSlashCommand(req, res, next) { if (req.body.command === '/interactive-example') { const type = req.body.text.split(' ')[0]; if (type === 'button') { res.json(interactiveButtons); } else if (type === 'menu') { res.json(interactiveMenu); } else if (type === 'dialog') { re...
[ "function", "slackSlashCommand", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "req", ".", "body", ".", "command", "===", "'/interactive-example'", ")", "{", "const", "type", "=", "req", ".", "body", ".", "text", ".", "split", "(", "' '", ...
Slack slash command handler
[ "Slack", "slash", "command", "handler" ]
0982098e1cd5356f7fde9f5b82a4c7eb9980f39f
https://github.com/slackapi/node-slack-interactive-messages/blob/0982098e1cd5356f7fde9f5b82a4c7eb9980f39f/examples/express-all-interactions/server.js#L217-L240
12,226
TalAter/UpUp
src/upup.js
function(settings) { this.addSettings(settings); // register the service worker _serviceWorker.register(_settings['service-worker-url'], _settings['registration-options']).then(function(registration) { // Registration was successful if (_debugState) { console.log('Service wo...
javascript
function(settings) { this.addSettings(settings); // register the service worker _serviceWorker.register(_settings['service-worker-url'], _settings['registration-options']).then(function(registration) { // Registration was successful if (_debugState) { console.log('Service wo...
[ "function", "(", "settings", ")", "{", "this", ".", "addSettings", "(", "settings", ")", ";", "// register the service worker", "_serviceWorker", ".", "register", "(", "_settings", "[", "'service-worker-url'", "]", ",", "_settings", "[", "'registration-options'", "]...
Make this site available offline Can receive a settings object directly, or be configured by running addSettings() first. See Settings section of docs for details. #### Examples: ````javascript // Set up offline mode with a basic message UpUp.start({ content: 'Cannot reach site. Please check your internet connection....
[ "Make", "this", "site", "available", "offline" ]
6bf4bab00bc6bece9567c07d478d3bae0ed71fc4
https://github.com/TalAter/UpUp/blob/6bf4bab00bc6bece9567c07d478d3bae0ed71fc4/src/upup.js#L161-L181
12,227
TalAter/UpUp
src/upup.js
function(settings) { settings = settings || {}; // if we got a string, instead of a settings object, use that string as the content if (typeof settings === 'string') { settings = { content: settings }; } // add new settings to our settings object [ 'content', ...
javascript
function(settings) { settings = settings || {}; // if we got a string, instead of a settings object, use that string as the content if (typeof settings === 'string') { settings = { content: settings }; } // add new settings to our settings object [ 'content', ...
[ "function", "(", "settings", ")", "{", "settings", "=", "settings", "||", "{", "}", ";", "// if we got a string, instead of a settings object, use that string as the content", "if", "(", "typeof", "settings", "===", "'string'", ")", "{", "settings", "=", "{", "content...
Adds settings to configure how UpUp behaves. Call this before running start, or just pass the settings object when calling the start method. Receives a mandatory settings object. See Settings section of docs for details. #### Examples: ````javascript // Set up offline mode with a basic message UpUp.addSettings({ cont...
[ "Adds", "settings", "to", "configure", "how", "UpUp", "behaves", ".", "Call", "this", "before", "running", "start", "or", "just", "pass", "the", "settings", "object", "when", "calling", "the", "start", "method", "." ]
6bf4bab00bc6bece9567c07d478d3bae0ed71fc4
https://github.com/TalAter/UpUp/blob/6bf4bab00bc6bece9567c07d478d3bae0ed71fc4/src/upup.js#L203-L228
12,228
TalAter/UpUp
src/upup.sw.js
function(input) { input = input.toString(); var hash = 0, i, chr, len = input.length; if (len === 0) { return hash; } for (i = 0; i < len; i++) { chr = input.charCodeAt(i); hash = (hash << 5) - hash + chr; hash |= 0; } return hash; }
javascript
function(input) { input = input.toString(); var hash = 0, i, chr, len = input.length; if (len === 0) { return hash; } for (i = 0; i < len; i++) { chr = input.charCodeAt(i); hash = (hash << 5) - hash + chr; hash |= 0; } return hash; }
[ "function", "(", "input", ")", "{", "input", "=", "input", ".", "toString", "(", ")", ";", "var", "hash", "=", "0", ",", "i", ",", "chr", ",", "len", "=", "input", ".", "length", ";", "if", "(", "len", "===", "0", ")", "{", "return", "hash", ...
Receives an input and calculates a hash for it
[ "Receives", "an", "input", "and", "calculates", "a", "hash", "for", "it" ]
6bf4bab00bc6bece9567c07d478d3bae0ed71fc4
https://github.com/TalAter/UpUp/blob/6bf4bab00bc6bece9567c07d478d3bae0ed71fc4/src/upup.sw.js#L11-L23
12,229
craftyjs/Crafty
src/graphics/layers.js
function(useCached) { var rect = this._cachedViewportRect; if (useCached) return rect; // total transform is viewport transform combined with this layer's transform var viewport = Crafty.viewport; var options = this.options; var scale = Math.pow(...
javascript
function(useCached) { var rect = this._cachedViewportRect; if (useCached) return rect; // total transform is viewport transform combined with this layer's transform var viewport = Crafty.viewport; var options = this.options; var scale = Math.pow(...
[ "function", "(", "useCached", ")", "{", "var", "rect", "=", "this", ".", "_cachedViewportRect", ";", "if", "(", "useCached", ")", "return", "rect", ";", "// total transform is viewport transform combined with this layer's transform", "var", "viewport", "=", "Crafty", ...
Based on the camera options, find the Crafty coordinates corresponding to the layer's position in the viewport
[ "Based", "on", "the", "camera", "options", "find", "the", "Crafty", "coordinates", "corresponding", "to", "the", "layer", "s", "position", "in", "the", "viewport" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/layers.js#L83-L114
12,230
craftyjs/Crafty
src/graphics/layers.js
function(rect, outRect, useCached) { var view = this._viewportRect(useCached), scale = view._scale; outRect = outRect || {}; outRect._x = rect._x * scale + Math.round(-view._x * scale); outRect._y = rect._y * scale + Math.round(-view._y * scale); ...
javascript
function(rect, outRect, useCached) { var view = this._viewportRect(useCached), scale = view._scale; outRect = outRect || {}; outRect._x = rect._x * scale + Math.round(-view._x * scale); outRect._y = rect._y * scale + Math.round(-view._y * scale); ...
[ "function", "(", "rect", ",", "outRect", ",", "useCached", ")", "{", "var", "view", "=", "this", ".", "_viewportRect", "(", "useCached", ")", ",", "scale", "=", "view", ".", "_scale", ";", "outRect", "=", "outRect", "||", "{", "}", ";", "outRect", "....
transform a given rect to view space, depending on this layers' total transform
[ "transform", "a", "given", "rect", "to", "view", "space", "depending", "on", "this", "layers", "total", "transform" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/layers.js#L117-L128
12,231
craftyjs/Crafty
src/spatial/2d.js
function(drad) { var cos = Math.cos(drad); cos = -1e-10 < cos && cos < 1e-10 ? 0 : cos; return cos; }
javascript
function(drad) { var cos = Math.cos(drad); cos = -1e-10 < cos && cos < 1e-10 ? 0 : cos; return cos; }
[ "function", "(", "drad", ")", "{", "var", "cos", "=", "Math", ".", "cos", "(", "drad", ")", ";", "cos", "=", "-", "1e-10", "<", "cos", "&&", "cos", "<", "1e-10", "?", "0", ":", "cos", ";", "return", "cos", ";", "}" ]
These versions of cos and sin ensure that rotations very close to 0 return 0. This avoids some problems where entities are not quite aligned with the grid.
[ "These", "versions", "of", "cos", "and", "sin", "ensure", "that", "rotations", "very", "close", "to", "0", "return", "0", ".", "This", "avoids", "some", "problems", "where", "entities", "are", "not", "quite", "aligned", "with", "the", "grid", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/spatial/2d.js#L11-L15
12,232
craftyjs/Crafty
src/spatial/2d.js
function(v) { //var theta = -1 * (v % 360); //angle always between 0 and 359 var difference = this._rotation - v; // skip if there's no rotation! if (difference === 0) return; else this._rotation = v; this._calculateMBR(); this.trigger("Rotate", difference); ...
javascript
function(v) { //var theta = -1 * (v % 360); //angle always between 0 and 359 var difference = this._rotation - v; // skip if there's no rotation! if (difference === 0) return; else this._rotation = v; this._calculateMBR(); this.trigger("Rotate", difference); ...
[ "function", "(", "v", ")", "{", "//var theta = -1 * (v % 360); //angle always between 0 and 359", "var", "difference", "=", "this", ".", "_rotation", "-", "v", ";", "// skip if there's no rotation!", "if", "(", "difference", "===", "0", ")", "return", ";", "else", "...
Handle changes that need to happen on a rotation
[ "Handle", "changes", "that", "need", "to", "happen", "on", "a", "rotation" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/spatial/2d.js#L434-L444
12,233
craftyjs/Crafty
src/spatial/2d.js
function(x, y) { if (x === this._x && y === this._y) return; var old = Crafty.rectManager._pool.copy(this); var mbr = this._mbr; if (mbr) { mbr._x -= this._x - x; mbr._y -= this._y - y; // cbr is a non-minimal bounding rectangle that contains both hitb...
javascript
function(x, y) { if (x === this._x && y === this._y) return; var old = Crafty.rectManager._pool.copy(this); var mbr = this._mbr; if (mbr) { mbr._x -= this._x - x; mbr._y -= this._y - y; // cbr is a non-minimal bounding rectangle that contains both hitb...
[ "function", "(", "x", ",", "y", ")", "{", "if", "(", "x", "===", "this", ".", "_x", "&&", "y", "===", "this", ".", "_y", ")", "return", ";", "var", "old", "=", "Crafty", ".", "rectManager", ".", "_pool", ".", "copy", "(", "this", ")", ";", "v...
A separate setter for the common case of moving an entity along both axes
[ "A", "separate", "setter", "for", "the", "common", "case", "of", "moving", "an", "entity", "along", "both", "axes" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/spatial/2d.js#L956-L975
12,234
craftyjs/Crafty
src/spatial/2d.js
function(name, value) { // Return if there is no change if (this[name] === value) { return; } //keep a reference of the old positions var old = Crafty.rectManager._pool.copy(this); var mbr; //if rotation, use the rotate method if (name === "_r...
javascript
function(name, value) { // Return if there is no change if (this[name] === value) { return; } //keep a reference of the old positions var old = Crafty.rectManager._pool.copy(this); var mbr; //if rotation, use the rotate method if (name === "_r...
[ "function", "(", "name", ",", "value", ")", "{", "// Return if there is no change", "if", "(", "this", "[", "name", "]", "===", "value", ")", "{", "return", ";", "}", "//keep a reference of the old positions", "var", "old", "=", "Crafty", ".", "rectManager", "...
This is a setter method for all 2D properties including x, y, w, h, and rotation.
[ "This", "is", "a", "setter", "method", "for", "all", "2D", "properties", "including", "x", "y", "w", "h", "and", "rotation", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/spatial/2d.js#L979-L1041
12,235
craftyjs/Crafty
src/inputs/mouse.js
function(eventName, e) { // trigger event on MouseSystem itself this.trigger(eventName, e); // special case: MouseOver & MouseOut var over = this.over, closest = e.target; if (eventName === "MouseMove" && over !== close...
javascript
function(eventName, e) { // trigger event on MouseSystem itself this.trigger(eventName, e); // special case: MouseOver & MouseOut var over = this.over, closest = e.target; if (eventName === "MouseMove" && over !== close...
[ "function", "(", "eventName", ",", "e", ")", "{", "// trigger event on MouseSystem itself", "this", ".", "trigger", "(", "eventName", ",", "e", ")", ";", "// special case: MouseOver & MouseOut", "var", "over", "=", "this", ".", "over", ",", "closest", "=", "e", ...
this method will be called by MouseState iff triggerMouse event was valid
[ "this", "method", "will", "be", "called", "by", "MouseState", "iff", "triggerMouse", "event", "was", "valid" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/inputs/mouse.js#L274-L308
12,236
craftyjs/Crafty
src/core/core.js
function(key, context) { var first, keys, subkey; if (typeof context === "undefined" || context === null) { context = this; } if (key.indexOf(".") > -1) { keys = key.split("."); first = keys.shift(); subkey = keys.join("."); ret...
javascript
function(key, context) { var first, keys, subkey; if (typeof context === "undefined" || context === null) { context = this; } if (key.indexOf(".") > -1) { keys = key.split("."); first = keys.shift(); subkey = keys.join("."); ret...
[ "function", "(", "key", ",", "context", ")", "{", "var", "first", ",", "keys", ",", "subkey", ";", "if", "(", "typeof", "context", "===", "\"undefined\"", "||", "context", "===", "null", ")", "{", "context", "=", "this", ";", "}", "if", "(", "key", ...
Internal getter method for data on the entity. Called by `.attr`. example ~~~ person._attr_get('name'); // Foxxy person._attr_get('contact'); // {email: 'fox_at_example.com'} person._attr_get('contact.email'); // fox_at_example.com ~~~
[ "Internal", "getter", "method", "for", "data", "on", "the", "entity", ".", "Called", "by", ".", "attr", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L617-L630
12,237
craftyjs/Crafty
src/core/core.js
function() { var data, silent, recursive; if (typeof arguments[0] === "string") { data = this._set_create_object(arguments[0], arguments[1]); silent = !!arguments[2]; recursive = arguments[3] || arguments[0].indexOf(".") > -1; } else { data = argum...
javascript
function() { var data, silent, recursive; if (typeof arguments[0] === "string") { data = this._set_create_object(arguments[0], arguments[1]); silent = !!arguments[2]; recursive = arguments[3] || arguments[0].indexOf(".") > -1; } else { data = argum...
[ "function", "(", ")", "{", "var", "data", ",", "silent", ",", "recursive", ";", "if", "(", "typeof", "arguments", "[", "0", "]", "===", "\"string\"", ")", "{", "data", "=", "this", ".", "_set_create_object", "(", "arguments", "[", "0", "]", ",", "arg...
Internal setter method for attributes on the component. Called by `.attr`. Options: `silent`: If you want to prevent it from firing events. `recursive`: If you pass in an object you could overwrite sibling keys, this recursively merges instead of just merging it. This is `false` by default, unless you are using dot ...
[ "Internal", "setter", "method", "for", "attributes", "on", "the", "component", ".", "Called", "by", ".", "attr", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L653-L675
12,238
craftyjs/Crafty
src/core/core.js
function(key, value) { var data = {}, keys, first, subkey; if (key.indexOf(".") > -1) { keys = key.split("."); first = keys.shift(); subkey = keys.join("."); data[first] = this._set_create_object(subkey, value); ...
javascript
function(key, value) { var data = {}, keys, first, subkey; if (key.indexOf(".") > -1) { keys = key.split("."); first = keys.shift(); subkey = keys.join("."); data[first] = this._set_create_object(subkey, value); ...
[ "function", "(", "key", ",", "value", ")", "{", "var", "data", "=", "{", "}", ",", "keys", ",", "first", ",", "subkey", ";", "if", "(", "key", ".", "indexOf", "(", "\".\"", ")", ">", "-", "1", ")", "{", "keys", "=", "key", ".", "split", "(", ...
If you are setting a key of 'foo.bar' or 'bar', this creates the appropriate object for you to recursively merge with the current attributes.
[ "If", "you", "are", "setting", "a", "key", "of", "foo", ".", "bar", "or", "bar", "this", "creates", "the", "appropriate", "object", "for", "you", "to", "recursively", "merge", "with", "the", "current", "attributes", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L682-L696
12,239
craftyjs/Crafty
src/core/core.js
function(new_data, original_data) { var key; for (key in new_data) { if (new_data[key].constructor === Object) { original_data[key] = this._recursive_extend( new_data[key], original_data[key] ); } else { ...
javascript
function(new_data, original_data) { var key; for (key in new_data) { if (new_data[key].constructor === Object) { original_data[key] = this._recursive_extend( new_data[key], original_data[key] ); } else { ...
[ "function", "(", "new_data", ",", "original_data", ")", "{", "var", "key", ";", "for", "(", "key", "in", "new_data", ")", "{", "if", "(", "new_data", "[", "key", "]", ".", "constructor", "===", "Object", ")", "{", "original_data", "[", "key", "]", "=...
Recursively puts `new_data` into `original_data`.
[ "Recursively", "puts", "new_data", "into", "original_data", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L701-L714
12,240
craftyjs/Crafty
src/core/core.js
function(event, fn) { // Get handle to event, creating it if necessary var callbacks = this._callbacks[event]; if (!callbacks) { callbacks = this._callbacks[event] = (handlers[event] || (handlers[event] = {}))[this[0]] = []; callbacks.context = this; ...
javascript
function(event, fn) { // Get handle to event, creating it if necessary var callbacks = this._callbacks[event]; if (!callbacks) { callbacks = this._callbacks[event] = (handlers[event] || (handlers[event] = {}))[this[0]] = []; callbacks.context = this; ...
[ "function", "(", "event", ",", "fn", ")", "{", "// Get handle to event, creating it if necessary", "var", "callbacks", "=", "this", ".", "_callbacks", "[", "event", "]", ";", "if", "(", "!", "callbacks", ")", "{", "callbacks", "=", "this", ".", "_callbacks", ...
Add a function to the list of callbacks for an event
[ "Add", "a", "function", "to", "the", "list", "of", "callbacks", "for", "an", "event" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L1276-L1287
12,241
craftyjs/Crafty
src/core/core.js
function(event, data) { if (!this._callbacks[event] || this.__callbacksFrozen) { return; } var callbacks = this._callbacks[event]; // Callback loop; deletes dead callbacks, but only when it is safe to do so var i, l = callbacks.length; // callback...
javascript
function(event, data) { if (!this._callbacks[event] || this.__callbacksFrozen) { return; } var callbacks = this._callbacks[event]; // Callback loop; deletes dead callbacks, but only when it is safe to do so var i, l = callbacks.length; // callback...
[ "function", "(", "event", ",", "data", ")", "{", "if", "(", "!", "this", ".", "_callbacks", "[", "event", "]", "||", "this", ".", "__callbacksFrozen", ")", "{", "return", ";", "}", "var", "callbacks", "=", "this", ".", "_callbacks", "[", "event", "]"...
Process for running all callbacks for the given event
[ "Process", "for", "running", "all", "callbacks", "for", "the", "given", "event" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L1290-L1318
12,242
craftyjs/Crafty
src/core/core.js
function(event, fn) { if (!this._callbacks[event]) { return; } var callbacks = this._callbacks[event]; // Iterate through and delete the callback functions that match // They are spliced out when _runCallbacks is invoked, not here // (This function might be ca...
javascript
function(event, fn) { if (!this._callbacks[event]) { return; } var callbacks = this._callbacks[event]; // Iterate through and delete the callback functions that match // They are spliced out when _runCallbacks is invoked, not here // (This function might be ca...
[ "function", "(", "event", ",", "fn", ")", "{", "if", "(", "!", "this", ".", "_callbacks", "[", "event", "]", ")", "{", "return", ";", "}", "var", "callbacks", "=", "this", ".", "_callbacks", "[", "event", "]", ";", "// Iterate through and delete the call...
Unbind callbacks for the given event If fn is specified, only it will be removed; otherwise all callbacks will be
[ "Unbind", "callbacks", "for", "the", "given", "event", "If", "fn", "is", "specified", "only", "it", "will", "be", "removed", ";", "otherwise", "all", "callbacks", "will", "be" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L1322-L1335
12,243
craftyjs/Crafty
src/core/core.js
function() { if (!this._callbacks) return; this.__callbacksFrozen = false; for (var event in this._callbacks) { if (this._callbacks[event]) { // Remove the normal way, in case we've got a nested loop this._unbindCallbacks(event); // Als...
javascript
function() { if (!this._callbacks) return; this.__callbacksFrozen = false; for (var event in this._callbacks) { if (this._callbacks[event]) { // Remove the normal way, in case we've got a nested loop this._unbindCallbacks(event); // Als...
[ "function", "(", ")", "{", "if", "(", "!", "this", ".", "_callbacks", ")", "return", ";", "this", ".", "__callbacksFrozen", "=", "false", ";", "for", "(", "var", "event", "in", "this", ".", "_callbacks", ")", "{", "if", "(", "this", ".", "_callbacks"...
Completely all callbacks for every event, such as on object destruction
[ "Completely", "all", "callbacks", "for", "every", "event", "such", "as", "on", "object", "destruction" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/core/core.js#L1338-L1349
12,244
craftyjs/Crafty
src/graphics/dom-layer.js
function(enabled) { var style = this._div.style; var camelize = Crafty.domHelper.camelize; if (enabled) { style[camelize("image-rendering")] = "optimizeSpeed"; /* legacy */ style[camelize("image-rendering")] = "-moz-crisp-edges"; /* Firefox */ ...
javascript
function(enabled) { var style = this._div.style; var camelize = Crafty.domHelper.camelize; if (enabled) { style[camelize("image-rendering")] = "optimizeSpeed"; /* legacy */ style[camelize("image-rendering")] = "-moz-crisp-edges"; /* Firefox */ ...
[ "function", "(", "enabled", ")", "{", "var", "style", "=", "this", ".", "_div", ".", "style", ";", "var", "camelize", "=", "Crafty", ".", "domHelper", ".", "camelize", ";", "if", "(", "enabled", ")", "{", "style", "[", "camelize", "(", "\"image-renderi...
Handle whether images should be smoothed or not
[ "Handle", "whether", "images", "should", "be", "smoothed", "or", "not" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/dom-layer.js#L58-L81
12,245
craftyjs/Crafty
src/graphics/dom-layer.js
function() { var style = this._div.style, view = this._viewportRect(); var scale = view._scale; var dx = -view._x * scale; var dy = -view._y * scale; style.transform = style[Crafty.support.prefix + "Transform"] = "scale(" + scale + ", " + scale + ")"; ...
javascript
function() { var style = this._div.style, view = this._viewportRect(); var scale = view._scale; var dx = -view._x * scale; var dy = -view._y * scale; style.transform = style[Crafty.support.prefix + "Transform"] = "scale(" + scale + ", " + scale + ")"; ...
[ "function", "(", ")", "{", "var", "style", "=", "this", ".", "_div", ".", "style", ",", "view", "=", "this", ".", "_viewportRect", "(", ")", ";", "var", "scale", "=", "view", ".", "_scale", ";", "var", "dx", "=", "-", "view", ".", "_x", "*", "s...
Sets the viewport position and scale Called by render when the dirtyViewport flag is set
[ "Sets", "the", "viewport", "position", "and", "scale", "Called", "by", "render", "when", "the", "dirtyViewport", "flag", "is", "set" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/dom-layer.js#L182-L195
12,246
craftyjs/Crafty
src/graphics/gl-textures.js
function() { var t; for (var i = 0; i < this.bound_textures.length; i++) { t = this.bound_textures[i]; t.unbind(); } this.bound_textures = []; this.active = null; }
javascript
function() { var t; for (var i = 0; i < this.bound_textures.length; i++) { t = this.bound_textures[i]; t.unbind(); } this.bound_textures = []; this.active = null; }
[ "function", "(", ")", "{", "var", "t", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "bound_textures", ".", "length", ";", "i", "++", ")", "{", "t", "=", "this", ".", "bound_textures", "[", "i", "]", ";", "t", ".", "unbin...
Clear out the bound textures and other existing state
[ "Clear", "out", "the", "bound", "textures", "and", "other", "existing", "state" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L22-L30
12,247
craftyjs/Crafty
src/graphics/gl-textures.js
function(url, image, repeating) { // gl is the context, webgl is the Crafty object containing prefs/etc // var gl = this.gl; var webgl = this.webgl; // Check whether a texture that matches the one requested already exists var id = "texture-(r:" + repeating + ")-" + url; ...
javascript
function(url, image, repeating) { // gl is the context, webgl is the Crafty object containing prefs/etc // var gl = this.gl; var webgl = this.webgl; // Check whether a texture that matches the one requested already exists var id = "texture-(r:" + repeating + ")-" + url; ...
[ "function", "(", "url", ",", "image", ",", "repeating", ")", "{", "// gl is the context, webgl is the Crafty object containing prefs/etc", "// var gl = this.gl;", "var", "webgl", "=", "this", ".", "webgl", ";", "// Check whether a texture that matches the one requested already ex...
creates a texture out of the given image and repeating state The url is just used to generate a unique id for the texture
[ "creates", "a", "texture", "out", "of", "the", "given", "image", "and", "repeating", "state", "The", "url", "is", "just", "used", "to", "generate", "a", "unique", "id", "for", "the", "texture" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L34-L55
12,248
craftyjs/Crafty
src/graphics/gl-textures.js
function() { var min_size = Infinity; var index = null; for (var i = 0; i < this.bound_textures.length; i++) { var t = this.bound_textures[i]; if (t.size < min_size) { min_size = t.size; index = i; } } return ind...
javascript
function() { var min_size = Infinity; var index = null; for (var i = 0; i < this.bound_textures.length; i++) { var t = this.bound_textures[i]; if (t.size < min_size) { min_size = t.size; index = i; } } return ind...
[ "function", "(", ")", "{", "var", "min_size", "=", "Infinity", ";", "var", "index", "=", "null", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "bound_textures", ".", "length", ";", "i", "++", ")", "{", "var", "t", "=", "thi...
Returns the bound texture of smallest size If we have more textures than available units, we should preferentially leave the larger textures bound?
[ "Returns", "the", "bound", "texture", "of", "smallest", "size", "If", "we", "have", "more", "textures", "than", "available", "units", "we", "should", "preferentially", "leave", "the", "larger", "textures", "bound?" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L59-L70
12,249
craftyjs/Crafty
src/graphics/gl-textures.js
function(t) { // return if the texture is already bound if (t.unit !== null) return; var i = this.getAvailableUnit(); if (this.bound_textures[i]) { this.unbindTexture(this.bound_textures[i]); } this.bound_textures[i] = t; t.bind(i); }
javascript
function(t) { // return if the texture is already bound if (t.unit !== null) return; var i = this.getAvailableUnit(); if (this.bound_textures[i]) { this.unbindTexture(this.bound_textures[i]); } this.bound_textures[i] = t; t.bind(i); }
[ "function", "(", "t", ")", "{", "// return if the texture is already bound", "if", "(", "t", ".", "unit", "!==", "null", ")", "return", ";", "var", "i", "=", "this", ".", "getAvailableUnit", "(", ")", ";", "if", "(", "this", ".", "bound_textures", "[", "...
takes a texture object and, if it isn't associated with a unit, binds it to one
[ "takes", "a", "texture", "object", "and", "if", "it", "isn", "t", "associated", "with", "a", "unit", "binds", "it", "to", "one" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L82-L91
12,250
craftyjs/Crafty
src/graphics/gl-textures.js
function(unit) { var gl = this.gl; this.unit = unit; this.name = "TEXTURE" + unit; this.manager.setActiveTexture(this); gl.bindTexture(gl.TEXTURE_2D, this.glTexture); }
javascript
function(unit) { var gl = this.gl; this.unit = unit; this.name = "TEXTURE" + unit; this.manager.setActiveTexture(this); gl.bindTexture(gl.TEXTURE_2D, this.glTexture); }
[ "function", "(", "unit", ")", "{", "var", "gl", "=", "this", ".", "gl", ";", "this", ".", "unit", "=", "unit", ";", "this", ".", "name", "=", "\"TEXTURE\"", "+", "unit", ";", "this", ".", "manager", ".", "setActiveTexture", "(", "this", ")", ";", ...
Given a number, binds to the corresponding texture unit
[ "Given", "a", "number", "binds", "to", "the", "corresponding", "texture", "unit" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L121-L127
12,251
craftyjs/Crafty
src/graphics/gl-textures.js
function(image) { if (!this.isActive()) throw "Trying to set image of texture that isn't active"; this.width = image.width; this.height = image.height; this.size = image.width * image.height; this.powerOfTwo = !( Math.log(image.width) / Math.LN2 !== ...
javascript
function(image) { if (!this.isActive()) throw "Trying to set image of texture that isn't active"; this.width = image.width; this.height = image.height; this.size = image.width * image.height; this.powerOfTwo = !( Math.log(image.width) / Math.LN2 !== ...
[ "function", "(", "image", ")", "{", "if", "(", "!", "this", ".", "isActive", "(", ")", ")", "throw", "\"Trying to set image of texture that isn't active\"", ";", "this", ".", "width", "=", "image", ".", "width", ";", "this", ".", "height", "=", "image", "....
actually loads an image into the texture object; sets the appropriate metadata
[ "actually", "loads", "an", "image", "into", "the", "texture", "object", ";", "sets", "the", "appropriate", "metadata" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L142-L163
12,252
craftyjs/Crafty
src/graphics/gl-textures.js
function(repeat) { if (!this.isActive()) throw "Trying to set repeat property of texture that isn't active"; if (repeat && !this.powerOfTwo) { throw "Can't create a repeating image whose dimensions aren't a power of 2 in WebGL contexts"; } var gl = this.gl; ...
javascript
function(repeat) { if (!this.isActive()) throw "Trying to set repeat property of texture that isn't active"; if (repeat && !this.powerOfTwo) { throw "Can't create a repeating image whose dimensions aren't a power of 2 in WebGL contexts"; } var gl = this.gl; ...
[ "function", "(", "repeat", ")", "{", "if", "(", "!", "this", ".", "isActive", "(", ")", ")", "throw", "\"Trying to set repeat property of texture that isn't active\"", ";", "if", "(", "repeat", "&&", "!", "this", ".", "powerOfTwo", ")", "{", "throw", "\"Can't ...
set image wrapping
[ "set", "image", "wrapping" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L175-L185
12,253
craftyjs/Crafty
src/graphics/gl-textures.js
function(shader, sampler_name, dimension_name) { if (this.unit === null) throw "Trying to use texture not set to a texture unit."; var gl = this.gl; gl.useProgram(shader); // Set the texture buffer to use gl.uniform1i(gl.getUniformLocation(shader, sampler_name), this....
javascript
function(shader, sampler_name, dimension_name) { if (this.unit === null) throw "Trying to use texture not set to a texture unit."; var gl = this.gl; gl.useProgram(shader); // Set the texture buffer to use gl.uniform1i(gl.getUniformLocation(shader, sampler_name), this....
[ "function", "(", "shader", ",", "sampler_name", ",", "dimension_name", ")", "{", "if", "(", "this", ".", "unit", "===", "null", ")", "throw", "\"Trying to use texture not set to a texture unit.\"", ";", "var", "gl", "=", "this", ".", "gl", ";", "gl", ".", "u...
given a shader and pair of uniform names, sets the sampler and dimensions to be used by this texture
[ "given", "a", "shader", "and", "pair", "of", "uniform", "names", "sets", "the", "sampler", "and", "dimensions", "to", "be", "used", "by", "this", "texture" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/gl-textures.js#L188-L201
12,254
craftyjs/Crafty
src/controls/controls-system.js
function(dpad, normalize) { var x = 0, y = 0; // Sum up all active directions for (var d in dpad.directions) { var dir = dpad.directions[d]; if (!dir.active) continue; x += dir.n.x; y += dir.n.y; } // Mitigate rounding...
javascript
function(dpad, normalize) { var x = 0, y = 0; // Sum up all active directions for (var d in dpad.directions) { var dir = dpad.directions[d]; if (!dir.active) continue; x += dir.n.x; y += dir.n.y; } // Mitigate rounding...
[ "function", "(", "dpad", ",", "normalize", ")", "{", "var", "x", "=", "0", ",", "y", "=", "0", ";", "// Sum up all active directions", "for", "(", "var", "d", "in", "dpad", ".", "directions", ")", "{", "var", "dir", "=", "dpad", ".", "directions", "[...
dpad definition is a map of directions to keys array and active flag
[ "dpad", "definition", "is", "a", "map", "of", "directions", "to", "keys", "array", "and", "active", "flag" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/controls/controls-system.js#L327-L354
12,255
craftyjs/Crafty
src/graphics/webgl-layer.js
RenderProgramWrapper
function RenderProgramWrapper(layer, shader) { this.shader = shader; this.layer = layer; this.context = layer.context; this.draw = function() {}; this.array_size = 16; this.max_size = 1024; this._indexArray = new Uint16Array(6 * this.array_size); this._indexBuffer = layer.context.create...
javascript
function RenderProgramWrapper(layer, shader) { this.shader = shader; this.layer = layer; this.context = layer.context; this.draw = function() {}; this.array_size = 16; this.max_size = 1024; this._indexArray = new Uint16Array(6 * this.array_size); this._indexBuffer = layer.context.create...
[ "function", "RenderProgramWrapper", "(", "layer", ",", "shader", ")", "{", "this", ".", "shader", "=", "shader", ";", "this", ".", "layer", "=", "layer", ";", "this", ".", "context", "=", "layer", ".", "context", ";", "this", ".", "draw", "=", "functio...
Object for abstracting out all the gl calls to handle rendering entities with a particular program
[ "Object", "for", "abstracting", "out", "all", "the", "gl", "calls", "to", "handle", "rendering", "entities", "with", "a", "particular", "program" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L5-L15
12,256
craftyjs/Crafty
src/graphics/webgl-layer.js
function(attributes) { this.attributes = attributes; this._attribute_table = {}; var offset = 0; for (var i = 0; i < attributes.length; i++) { var a = attributes[i]; this._attribute_table[a.name] = a; a.bytes = a.bytes || Float32Array.BYTES_PER_ELEMEN...
javascript
function(attributes) { this.attributes = attributes; this._attribute_table = {}; var offset = 0; for (var i = 0; i < attributes.length; i++) { var a = attributes[i]; this._attribute_table[a.name] = a; a.bytes = a.bytes || Float32Array.BYTES_PER_ELEMEN...
[ "function", "(", "attributes", ")", "{", "this", ".", "attributes", "=", "attributes", ";", "this", ".", "_attribute_table", "=", "{", "}", ";", "var", "offset", "=", "0", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "attributes", ".", "le...
Takes an array of attributes; see WebGLLayer's getProgramWrapper method
[ "Takes", "an", "array", "of", "attributes", ";", "see", "WebGLLayer", "s", "getProgramWrapper", "method" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L19-L47
12,257
craftyjs/Crafty
src/graphics/webgl-layer.js
function(size) { if (this.array_size >= this.max_size) return; var newsize = Math.min(size, this.max_size); var newAttributeArray = new Float32Array(newsize * 4 * this.stride); var newIndexArray = new Uint16Array(6 * newsize); newAttributeArray.set(this._attributeArray); ...
javascript
function(size) { if (this.array_size >= this.max_size) return; var newsize = Math.min(size, this.max_size); var newAttributeArray = new Float32Array(newsize * 4 * this.stride); var newIndexArray = new Uint16Array(6 * newsize); newAttributeArray.set(this._attributeArray); ...
[ "function", "(", "size", ")", "{", "if", "(", "this", ".", "array_size", ">=", "this", ".", "max_size", ")", "return", ";", "var", "newsize", "=", "Math", ".", "min", "(", "size", ",", "this", ".", "max_size", ")", ";", "var", "newAttributeArray", "=...
increase the size of the typed arrays does so by creating a new array of that size and copying the existing one into it
[ "increase", "the", "size", "of", "the", "typed", "arrays", "does", "so", "by", "creating", "a", "new", "array", "of", "that", "size", "and", "copying", "the", "existing", "one", "into", "it" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L51-L65
12,258
craftyjs/Crafty
src/graphics/webgl-layer.js
function(e) { if (this._registryHoles.length === 0) { if (this._registrySize >= this.max_size) { throw "Number of entities exceeds maximum limit."; } else if (this._registrySize >= this.array_size) { this.growArrays(2 * this.array_size); } ...
javascript
function(e) { if (this._registryHoles.length === 0) { if (this._registrySize >= this.max_size) { throw "Number of entities exceeds maximum limit."; } else if (this._registrySize >= this.array_size) { this.growArrays(2 * this.array_size); } ...
[ "function", "(", "e", ")", "{", "if", "(", "this", ".", "_registryHoles", ".", "length", "===", "0", ")", "{", "if", "(", "this", ".", "_registrySize", ">=", "this", ".", "max_size", ")", "{", "throw", "\"Number of entities exceeds maximum limit.\"", ";", ...
Add an entity that needs to be rendered by this program Needs to be assigned an index in the buffer
[ "Add", "an", "entity", "that", "needs", "to", "be", "rendered", "by", "this", "program", "Needs", "to", "be", "assigned", "an", "index", "in", "the", "buffer" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L69-L81
12,259
craftyjs/Crafty
src/graphics/webgl-layer.js
function(e) { if (typeof e._glBufferIndex === "number") this._registryHoles.push(e._glBufferIndex); e._glBufferIndex = null; }
javascript
function(e) { if (typeof e._glBufferIndex === "number") this._registryHoles.push(e._glBufferIndex); e._glBufferIndex = null; }
[ "function", "(", "e", ")", "{", "if", "(", "typeof", "e", ".", "_glBufferIndex", "===", "\"number\"", ")", "this", ".", "_registryHoles", ".", "push", "(", "e", ".", "_glBufferIndex", ")", ";", "e", ".", "_glBufferIndex", "=", "null", ";", "}" ]
remove an entity; allow its buffer index to be reused
[ "remove", "an", "entity", ";", "allow", "its", "buffer", "index", "to", "be", "reused" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L84-L88
12,260
craftyjs/Crafty
src/graphics/webgl-layer.js
function() { var gl = this.context; gl.useProgram(this.shader); gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer); var a, attributes = this.attributes; // Process every attribute for (var i = 0; i < attributes.length; i++) { a = attributes[i]; ...
javascript
function() { var gl = this.context; gl.useProgram(this.shader); gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer); var a, attributes = this.attributes; // Process every attribute for (var i = 0; i < attributes.length; i++) { a = attributes[i]; ...
[ "function", "(", ")", "{", "var", "gl", "=", "this", ".", "context", ";", "gl", ".", "useProgram", "(", "this", ".", "shader", ")", ";", "gl", ".", "bindBuffer", "(", "gl", ".", "ARRAY_BUFFER", ",", "this", ".", "_attributeBuffer", ")", ";", "var", ...
Called before a batch of entities is prepped for rendering
[ "Called", "before", "a", "batch", "of", "entities", "is", "prepped", "for", "rendering" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L102-L128
12,261
craftyjs/Crafty
src/graphics/webgl-layer.js
function(offset) { var index = this._indexArray, l = this.index_pointer; index[0 + l] = 0 + offset; index[1 + l] = 1 + offset; index[2 + l] = 2 + offset; index[3 + l] = 1 + offset; index[4 + l] = 2 + offset; index[5 + l] = 3 + offset; this.inde...
javascript
function(offset) { var index = this._indexArray, l = this.index_pointer; index[0 + l] = 0 + offset; index[1 + l] = 1 + offset; index[2 + l] = 2 + offset; index[3 + l] = 1 + offset; index[4 + l] = 2 + offset; index[5 + l] = 3 + offset; this.inde...
[ "function", "(", "offset", ")", "{", "var", "index", "=", "this", ".", "_indexArray", ",", "l", "=", "this", ".", "index_pointer", ";", "index", "[", "0", "+", "l", "]", "=", "0", "+", "offset", ";", "index", "[", "1", "+", "l", "]", "=", "1", ...
adds a set of 6 indices to the index array Corresponds to 2 triangles that make up a rectangle
[ "adds", "a", "set", "of", "6", "indices", "to", "the", "index", "array", "Corresponds", "to", "2", "triangles", "that", "make", "up", "a", "rectangle" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L141-L151
12,262
craftyjs/Crafty
src/graphics/webgl-layer.js
function() { var gl = this.context; gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer); gl.bufferData(gl.ARRAY_BUFFER, this._attributeArray, gl.STATIC_DRAW); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); gl.bufferData( gl.ELEMENT_ARRAY_BUFFER, ...
javascript
function() { var gl = this.context; gl.bindBuffer(gl.ARRAY_BUFFER, this._attributeBuffer); gl.bufferData(gl.ARRAY_BUFFER, this._attributeArray, gl.STATIC_DRAW); gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer); gl.bufferData( gl.ELEMENT_ARRAY_BUFFER, ...
[ "function", "(", ")", "{", "var", "gl", "=", "this", ".", "context", ";", "gl", ".", "bindBuffer", "(", "gl", ".", "ARRAY_BUFFER", ",", "this", ".", "_attributeBuffer", ")", ";", "gl", ".", "bufferData", "(", "gl", ".", "ARRAY_BUFFER", ",", "this", "...
Writes data from the attribute and index arrays to the appropriate buffers, and then calls drawElements.
[ "Writes", "data", "from", "the", "attribute", "and", "index", "arrays", "to", "the", "appropriate", "buffers", "and", "then", "calls", "drawElements", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L154-L165
12,263
craftyjs/Crafty
src/graphics/webgl-layer.js
function(src, type) { var gl = this.context; var shader = gl.createShader(type); gl.shaderSource(shader, src); gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { throw gl.getShaderInfoLog(shader); } return shader; }
javascript
function(src, type) { var gl = this.context; var shader = gl.createShader(type); gl.shaderSource(shader, src); gl.compileShader(shader); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { throw gl.getShaderInfoLog(shader); } return shader; }
[ "function", "(", "src", ",", "type", ")", "{", "var", "gl", "=", "this", ".", "context", ";", "var", "shader", "=", "gl", ".", "createShader", "(", "type", ")", ";", "gl", ".", "shaderSource", "(", "shader", ",", "src", ")", ";", "gl", ".", "comp...
Create a vertex or fragment shader, given the source and type
[ "Create", "a", "vertex", "or", "fragment", "shader", "given", "the", "source", "and", "type" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L218-L227
12,264
craftyjs/Crafty
src/graphics/webgl-layer.js
function(shader) { var gl = this.context; var fragmentShader = this._compileShader( shader.fragmentCode, gl.FRAGMENT_SHADER ); var vertexShader = this._compileShader( shader.vertexCode, gl.VERTEX_SHADER ); var shaderProgram...
javascript
function(shader) { var gl = this.context; var fragmentShader = this._compileShader( shader.fragmentCode, gl.FRAGMENT_SHADER ); var vertexShader = this._compileShader( shader.vertexCode, gl.VERTEX_SHADER ); var shaderProgram...
[ "function", "(", "shader", ")", "{", "var", "gl", "=", "this", ".", "context", ";", "var", "fragmentShader", "=", "this", ".", "_compileShader", "(", "shader", ".", "fragmentCode", ",", "gl", ".", "FRAGMENT_SHADER", ")", ";", "var", "vertexShader", "=", ...
Create and return a complete, linked shader program, given the source for the fragment and vertex shaders. Will compile the two shaders and then link them together
[ "Create", "and", "return", "a", "complete", "linked", "shader", "program", "given", "the", "source", "for", "the", "fragment", "and", "vertex", "shaders", ".", "Will", "compile", "the", "two", "shaders", "and", "then", "link", "them", "together" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L231-L256
12,265
craftyjs/Crafty
src/graphics/webgl-layer.js
function() { var c = this._canvas; c.width = Crafty.viewport.width; c.height = Crafty.viewport.height; var gl = this.context; gl.viewportWidth = c.width; gl.viewportHeight = c.height; }
javascript
function() { var c = this._canvas; c.width = Crafty.viewport.width; c.height = Crafty.viewport.height; var gl = this.context; gl.viewportWidth = c.width; gl.viewportHeight = c.height; }
[ "function", "(", ")", "{", "var", "c", "=", "this", ".", "_canvas", ";", "c", ".", "width", "=", "Crafty", ".", "viewport", ".", "width", ";", "c", ".", "height", "=", "Crafty", ".", "viewport", ".", "height", ";", "var", "gl", "=", "this", ".", ...
Called when the viewport resizes
[ "Called", "when", "the", "viewport", "resizes" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L365-L373
12,266
craftyjs/Crafty
src/graphics/webgl-layer.js
function(rect) { rect = rect || this._viewportRect(); var gl = this.context; // Set viewport and clear it gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); //Set the viewport uniform variables used by each regis...
javascript
function(rect) { rect = rect || this._viewportRect(); var gl = this.context; // Set viewport and clear it gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); //Set the viewport uniform variables used by each regis...
[ "function", "(", "rect", ")", "{", "rect", "=", "rect", "||", "this", ".", "_viewportRect", "(", ")", ";", "var", "gl", "=", "this", ".", "context", ";", "// Set viewport and clear it", "gl", ".", "viewport", "(", "0", ",", "0", ",", "gl", ".", "view...
Render any entities associated with this context; called in response to a draw event
[ "Render", "any", "entities", "associated", "with", "this", "context", ";", "called", "in", "response", "to", "a", "draw", "event" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl-layer.js#L389-L453
12,267
craftyjs/Crafty
src/graphics/text.js
function(propertyName) { // could check for DOM component, but this event should only be fired by such an entity! // Rather than triggering Invalidate on each of these, we rely on css() triggering that event switch (propertyName) { case "textAlign": ...
javascript
function(propertyName) { // could check for DOM component, but this event should only be fired by such an entity! // Rather than triggering Invalidate on each of these, we rely on css() triggering that event switch (propertyName) { case "textAlign": ...
[ "function", "(", "propertyName", ")", "{", "// could check for DOM component, but this event should only be fired by such an entity!", "// Rather than triggering Invalidate on each of these, we rely on css() triggering that event", "switch", "(", "propertyName", ")", "{", "case", "\"textAl...
type, weight, size, family, lineHeight, and variant. For a few hardcoded css properties, set the internal definitions
[ "type", "weight", "size", "family", "lineHeight", "and", "variant", ".", "For", "a", "few", "hardcoded", "css", "properties", "set", "the", "internal", "definitions" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/text.js#L81-L111
12,268
craftyjs/Crafty
src/graphics/text.js
function() { return ( this._textFont.type + " " + this._textFont.variant + " " + this._textFont.weight + " " + this._textFont.size + " / " + this._textFont.lineHeight + " " + this....
javascript
function() { return ( this._textFont.type + " " + this._textFont.variant + " " + this._textFont.weight + " " + this._textFont.size + " / " + this._textFont.lineHeight + " " + this....
[ "function", "(", ")", "{", "return", "(", "this", ".", "_textFont", ".", "type", "+", "\" \"", "+", "this", ".", "_textFont", ".", "variant", "+", "\" \"", "+", "this", ".", "_textFont", ".", "weight", "+", "\" \"", "+", "this", ".", "_textFont", "."...
Returns the font string to use
[ "Returns", "the", "font", "string", "to", "use" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/text.js#L259-L273
12,269
craftyjs/Crafty
src/graphics/webgl.js
function(compName, shader) { this.program = this._drawLayer.getProgramWrapper(compName, shader); // Needs to know where in the big array we are! this.program.registerEntity(this); // Shader program means ready this.ready = true; }
javascript
function(compName, shader) { this.program = this._drawLayer.getProgramWrapper(compName, shader); // Needs to know where in the big array we are! this.program.registerEntity(this); // Shader program means ready this.ready = true; }
[ "function", "(", "compName", ",", "shader", ")", "{", "this", ".", "program", "=", "this", ".", "_drawLayer", ".", "getProgramWrapper", "(", "compName", ",", "shader", ")", ";", "// Needs to know where in the big array we are!", "this", ".", "program", ".", "reg...
v_src is optional, there's a default vertex shader that works for regular rectangular entities
[ "v_src", "is", "optional", "there", "s", "a", "default", "vertex", "shader", "that", "works", "for", "regular", "rectangular", "entities" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/webgl.js#L282-L289
12,270
craftyjs/Crafty
src/sound/sound.js
function() { this.supported = {}; // Without support, no formats are supported if (!Crafty.support.audio) return; var audio = this.audioElement(), canplay; for (var i in this.codecs) { canplay = audio.canPlayType(this.codecs[i])...
javascript
function() { this.supported = {}; // Without support, no formats are supported if (!Crafty.support.audio) return; var audio = this.audioElement(), canplay; for (var i in this.codecs) { canplay = audio.canPlayType(this.codecs[i])...
[ "function", "(", ")", "{", "this", ".", "supported", "=", "{", "}", ";", "// Without support, no formats are supported", "if", "(", "!", "Crafty", ".", "support", ".", "audio", ")", "return", ";", "var", "audio", "=", "this", ".", "audioElement", "(", ")",...
Function to setup supported formats
[ "Function", "to", "setup", "supported", "formats" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/sound/sound.js#L36-L50
12,271
craftyjs/Crafty
src/sound/sound.js
function() { for (var i = 0; i < this.channels.length; i++) { var chan = this.channels[i]; /* * Second test looks for stuff that's out of use, * but fallen foul of Chromium bug 280417 */ if ( ...
javascript
function() { for (var i = 0; i < this.channels.length; i++) { var chan = this.channels[i]; /* * Second test looks for stuff that's out of use, * but fallen foul of Chromium bug 280417 */ if ( ...
[ "function", "(", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "this", ".", "channels", ".", "length", ";", "i", "++", ")", "{", "var", "chan", "=", "this", ".", "channels", "[", "i", "]", ";", "/*\n * Second test looks...
Finds an unused audio element, marks it as in use, and return it.
[ "Finds", "an", "unused", "audio", "element", "marks", "it", "as", "in", "use", "and", "return", "it", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/sound/sound.js#L270-L301
12,272
craftyjs/Crafty
src/graphics/image.js
function(layer) { if (!this.img || !layer) return; if (layer.type === "Canvas") { this._pattern = this._drawContext.createPattern( this.img, this._repeat ); } else if (layer.type === "WebGL") { this._establishShader( ...
javascript
function(layer) { if (!this.img || !layer) return; if (layer.type === "Canvas") { this._pattern = this._drawContext.createPattern( this.img, this._repeat ); } else if (layer.type === "WebGL") { this._establishShader( ...
[ "function", "(", "layer", ")", "{", "if", "(", "!", "this", ".", "img", "||", "!", "layer", ")", "return", ";", "if", "(", "layer", ".", "type", "===", "\"Canvas\"", ")", "{", "this", ".", "_pattern", "=", "this", ".", "_drawContext", ".", "createP...
called on image change or layer attachment
[ "called", "on", "image", "change", "or", "layer", "attachment" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/image.js#L124-L153
12,273
craftyjs/Crafty
src/graphics/dom.js
function() { var comp, c = this.__c, str = ""; for (comp in c) { str += " " + comp; } str = str.substr(1); this._element.className = str; }
javascript
function() { var comp, c = this.__c, str = ""; for (comp in c) { str += " " + comp; } str = str.substr(1); this._element.className = str; }
[ "function", "(", ")", "{", "var", "comp", ",", "c", "=", "this", ".", "__c", ",", "str", "=", "\"\"", ";", "for", "(", "comp", "in", "c", ")", "{", "str", "+=", "\" \"", "+", "comp", ";", "}", "str", "=", "str", ".", "substr", "(", "1", ")"...
adds a class on NewComponent events
[ "adds", "a", "class", "on", "NewComponent", "events" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/dom.js#L90-L99
12,274
craftyjs/Crafty
src/debug/logging.js
function() { if ( Crafty.loggingEnabled && (typeof window !== "undefined" ? window.console : console) && console.log ) { console.log.apply(console, arguments); } }
javascript
function() { if ( Crafty.loggingEnabled && (typeof window !== "undefined" ? window.console : console) && console.log ) { console.log.apply(console, arguments); } }
[ "function", "(", ")", "{", "if", "(", "Crafty", ".", "loggingEnabled", "&&", "(", "typeof", "window", "!==", "\"undefined\"", "?", "window", ".", "console", ":", "console", ")", "&&", "console", ".", "log", ")", "{", "console", ".", "log", ".", "apply"...
In some cases console.log doesn't exist, so provide a wrapper for it
[ "In", "some", "cases", "console", ".", "log", "doesn", "t", "exist", "so", "provide", "a", "wrapper", "for", "it" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/debug/logging.js#L29-L37
12,275
craftyjs/Crafty
src/spatial/collision.js
function(e) { var dx, dy, rot = this.rotation * DEG_TO_RAD, points = this.map.points; // Depending on the change of axis, move the corners of the rectangle appropriately if (e.axis === "w") { if (rot) { dx = e.amount * Math.cos(rot...
javascript
function(e) { var dx, dy, rot = this.rotation * DEG_TO_RAD, points = this.map.points; // Depending on the change of axis, move the corners of the rectangle appropriately if (e.axis === "w") { if (rot) { dx = e.amount * Math.cos(rot...
[ "function", "(", "e", ")", "{", "var", "dx", ",", "dy", ",", "rot", "=", "this", ".", "rotation", "*", "DEG_TO_RAD", ",", "points", "=", "this", ".", "map", ".", "points", ";", "// Depending on the change of axis, move the corners of the rectangle appropriately", ...
The default behavior is to match the hitbox to the entity. This function will change the hitbox when a "Resize" event triggers.
[ "The", "default", "behavior", "is", "to", "match", "the", "hitbox", "to", "the", "entity", ".", "This", "function", "will", "change", "the", "hitbox", "when", "a", "Resize", "event", "triggers", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/spatial/collision.js#L410-L446
12,276
craftyjs/Crafty
src/spatial/collision.js
function(component, collisionData) { return function() { var hitData = this.hit(component); if (collisionData.occurring === true) { if (hitData !== null) { // The collision is still in progress return; } ...
javascript
function(component, collisionData) { return function() { var hitData = this.hit(component); if (collisionData.occurring === true) { if (hitData !== null) { // The collision is still in progress return; } ...
[ "function", "(", "component", ",", "collisionData", ")", "{", "return", "function", "(", ")", "{", "var", "hitData", "=", "this", ".", "hit", "(", "component", ")", ";", "if", "(", "collisionData", ".", "occurring", "===", "true", ")", "{", "if", "(", ...
This is a helper method for creating collisions handlers set up by `checkHits`. Do not call this directly. @param {String} component - The name of the component for which this handler checks for collisions. @param {Object} collisionData - Collision data object used to track collisions with the specified component. @s...
[ "This", "is", "a", "helper", "method", "for", "creating", "collisions", "handlers", "set", "up", "by", "checkHits", ".", "Do", "not", "call", "this", "directly", "." ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/spatial/collision.js#L646-L663
12,277
craftyjs/Crafty
src/graphics/color.js
function(e) { if (!this._color) { return; } if (e.type === "DOM") { e.style.backgroundColor = this._color; e.style.lineHeight = 0; } else if (e.type === "canvas") { e.ctx.fillStyle = this._color; e.ctx.fillRect(e.pos._x, e.pos._...
javascript
function(e) { if (!this._color) { return; } if (e.type === "DOM") { e.style.backgroundColor = this._color; e.style.lineHeight = 0; } else if (e.type === "canvas") { e.ctx.fillStyle = this._color; e.ctx.fillRect(e.pos._x, e.pos._...
[ "function", "(", "e", ")", "{", "if", "(", "!", "this", ".", "_color", ")", "{", "return", ";", "}", "if", "(", "e", ".", "type", "===", "\"DOM\"", ")", "{", "e", ".", "style", ".", "backgroundColor", "=", "this", ".", "_color", ";", "e", ".", ...
draw function for "Color"
[ "draw", "function", "for", "Color" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/graphics/color.js#L230-L243
12,278
craftyjs/Crafty
src/inputs/touch.js
function(eventName, e) { // trigger event on TouchSystem itself this.trigger(eventName, e); var identifier = e.identifier, closest = e.target, over = this.overs[identifier]; if (over) { // if ol...
javascript
function(eventName, e) { // trigger event on TouchSystem itself this.trigger(eventName, e); var identifier = e.identifier, closest = e.target, over = this.overs[identifier]; if (over) { // if ol...
[ "function", "(", "eventName", ",", "e", ")", "{", "// trigger event on TouchSystem itself", "this", ".", "trigger", "(", "eventName", ",", "e", ")", ";", "var", "identifier", "=", "e", ".", "identifier", ",", "closest", "=", "e", ".", "target", ",", "over"...
this method will be called by TouchState iff triggerTouch event was valid
[ "this", "method", "will", "be", "called", "by", "TouchState", "iff", "triggerTouch", "event", "was", "valid" ]
f3982baa51af24d4e8a14a3194fd3f0e92a2dcba
https://github.com/craftyjs/Crafty/blob/f3982baa51af24d4e8a14a3194fd3f0e92a2dcba/src/inputs/touch.js#L214-L266
12,279
andywer/webpack-blocks
packages/core/lib/env.js
env
function env(envName, configSetters) { assertConfigSetters(configSetters) const currentEnv = process.env.NODE_ENV || 'development' if (currentEnv !== envName) { return () => config => config } else { return group(configSetters) } }
javascript
function env(envName, configSetters) { assertConfigSetters(configSetters) const currentEnv = process.env.NODE_ENV || 'development' if (currentEnv !== envName) { return () => config => config } else { return group(configSetters) } }
[ "function", "env", "(", "envName", ",", "configSetters", ")", "{", "assertConfigSetters", "(", "configSetters", ")", "const", "currentEnv", "=", "process", ".", "env", ".", "NODE_ENV", "||", "'development'", "if", "(", "currentEnv", "!==", "envName", ")", "{",...
Applies an array of webpack blocks only if `process.env.NODE_ENV` matches the given `envName`. If no `NODE_ENV` is set, it will be treated as 'development'. @param {string} envName Environment name like 'development', 'production' or 'testing'. @param {Function[]} configSetters Array of functions as return...
[ "Applies", "an", "array", "of", "webpack", "blocks", "only", "if", "process", ".", "env", ".", "NODE_ENV", "matches", "the", "given", "envName", ".", "If", "no", "NODE_ENV", "is", "set", "it", "will", "be", "treated", "as", "development", "." ]
dca0f219a6551b727494a53e043f87694422a546
https://github.com/andywer/webpack-blocks/blob/dca0f219a6551b727494a53e043f87694422a546/packages/core/lib/env.js#L14-L24
12,280
andywer/webpack-blocks
packages/core/lib/when.js
when
function when(condition, configSetters) { assertConfigSetters(configSetters) if (condition) { return group(configSetters) } else { return () => config => config } }
javascript
function when(condition, configSetters) { assertConfigSetters(configSetters) if (condition) { return group(configSetters) } else { return () => config => config } }
[ "function", "when", "(", "condition", ",", "configSetters", ")", "{", "assertConfigSetters", "(", "configSetters", ")", "if", "(", "condition", ")", "{", "return", "group", "(", "configSetters", ")", "}", "else", "{", "return", "(", ")", "=>", "config", "=...
Applies an array of webpack blocks only if `condition` is true. @param {boolean} condition Condition to test @param {Function[]} configSetters Array of functions as returned by webpack blocks. @return {Function}
[ "Applies", "an", "array", "of", "webpack", "blocks", "only", "if", "condition", "is", "true", "." ]
dca0f219a6551b727494a53e043f87694422a546
https://github.com/andywer/webpack-blocks/blob/dca0f219a6551b727494a53e043f87694422a546/packages/core/lib/when.js#L13-L21
12,281
andywer/webpack-blocks
packages/webpack/lib/parseVersion.js
parseVersion
function parseVersion(versionString) { const [release, prerelease] = versionString.split('-') const splitRelease = release.split('.').map(number => parseInt(number, 10)) return { major: splitRelease[0], minor: splitRelease[1], patch: splitRelease[2], prerelease: prerelease || '', raw: version...
javascript
function parseVersion(versionString) { const [release, prerelease] = versionString.split('-') const splitRelease = release.split('.').map(number => parseInt(number, 10)) return { major: splitRelease[0], minor: splitRelease[1], patch: splitRelease[2], prerelease: prerelease || '', raw: version...
[ "function", "parseVersion", "(", "versionString", ")", "{", "const", "[", "release", ",", "prerelease", "]", "=", "versionString", ".", "split", "(", "'-'", ")", "const", "splitRelease", "=", "release", ".", "split", "(", "'.'", ")", ".", "map", "(", "nu...
Parse semver-compliant version string. @param {string} versionString @return {object} { major: number, minor: number, patch: number, prerelease: string, raw: string }
[ "Parse", "semver", "-", "compliant", "version", "string", "." ]
dca0f219a6551b727494a53e043f87694422a546
https://github.com/andywer/webpack-blocks/blob/dca0f219a6551b727494a53e043f87694422a546/packages/webpack/lib/parseVersion.js#L9-L20
12,282
andywer/webpack-blocks
packages/webpack/lib/setEnv.js
setEnv
function setEnv(constants) { const setter = context => prevConfig => { context.setEnv = Object.assign({}, context.setEnv, toObject(constants)) return prevConfig } return Object.assign(setter, { post: addEnvironmentPlugin }) }
javascript
function setEnv(constants) { const setter = context => prevConfig => { context.setEnv = Object.assign({}, context.setEnv, toObject(constants)) return prevConfig } return Object.assign(setter, { post: addEnvironmentPlugin }) }
[ "function", "setEnv", "(", "constants", ")", "{", "const", "setter", "=", "context", "=>", "prevConfig", "=>", "{", "context", ".", "setEnv", "=", "Object", ".", "assign", "(", "{", "}", ",", "context", ".", "setEnv", ",", "toObject", "(", "constants", ...
Replaces constants in your source code with values from `process.env` using the `webpack.EnvironmentPlugin`. Using `setEnv` multiple times results in a single EnvironmentPlugin instance configured to do all the replacements. @param {string[]|object} constants @return {Function}
[ "Replaces", "constants", "in", "your", "source", "code", "with", "values", "from", "process", ".", "env", "using", "the", "webpack", ".", "EnvironmentPlugin", "." ]
dca0f219a6551b727494a53e043f87694422a546
https://github.com/andywer/webpack-blocks/blob/dca0f219a6551b727494a53e043f87694422a546/packages/webpack/lib/setEnv.js#L13-L20
12,283
andywer/webpack-blocks
packages/core/lib/group.js
group
function group(configSetters) { assertConfigSetters(configSetters) const pre = getHooks(configSetters, 'pre') const post = getHooks(configSetters, 'post') const groupBlock = context => config => invokeConfigSetters(configSetters, context, config) return Object.assign(groupBlock, { pre, post }) }
javascript
function group(configSetters) { assertConfigSetters(configSetters) const pre = getHooks(configSetters, 'pre') const post = getHooks(configSetters, 'post') const groupBlock = context => config => invokeConfigSetters(configSetters, context, config) return Object.assign(groupBlock, { pre, post }) }
[ "function", "group", "(", "configSetters", ")", "{", "assertConfigSetters", "(", "configSetters", ")", "const", "pre", "=", "getHooks", "(", "configSetters", ",", "'pre'", ")", "const", "post", "=", "getHooks", "(", "configSetters", ",", "'post'", ")", "const"...
Combines an array of blocks to a new joined block. Running this single block has the same effect as running all source blocks. @param {Function[]} configSetters Array of functions as returned by webpack blocks. @return {Function}
[ "Combines", "an", "array", "of", "blocks", "to", "a", "new", "joined", "block", ".", "Running", "this", "single", "block", "has", "the", "same", "effect", "as", "running", "all", "source", "blocks", "." ]
dca0f219a6551b727494a53e043f87694422a546
https://github.com/andywer/webpack-blocks/blob/dca0f219a6551b727494a53e043f87694422a546/packages/core/lib/group.js#L13-L22
12,284
andywer/webpack-blocks
packages/core/lib/configSetters.js
assertConfigSetters
function assertConfigSetters(configSetters) { if (!Array.isArray(configSetters)) { throw new Error( `Expected parameter 'configSetters' to be an array of functions. Instead got ${configSetters}.` ) } if (!configSetters.every(_.isFunction)) { const invalidElementIndex = configSetters.findIndex(se...
javascript
function assertConfigSetters(configSetters) { if (!Array.isArray(configSetters)) { throw new Error( `Expected parameter 'configSetters' to be an array of functions. Instead got ${configSetters}.` ) } if (!configSetters.every(_.isFunction)) { const invalidElementIndex = configSetters.findIndex(se...
[ "function", "assertConfigSetters", "(", "configSetters", ")", "{", "if", "(", "!", "Array", ".", "isArray", "(", "configSetters", ")", ")", "{", "throw", "new", "Error", "(", "`", "${", "configSetters", "}", "`", ")", "}", "if", "(", "!", "configSetters"...
Asserts that given param is an array of functions. @param {Function[]} configSetters Array of functions as returned by webpack blocks.
[ "Asserts", "that", "given", "param", "is", "an", "array", "of", "functions", "." ]
dca0f219a6551b727494a53e043f87694422a546
https://github.com/andywer/webpack-blocks/blob/dca0f219a6551b727494a53e043f87694422a546/packages/core/lib/configSetters.js#L14-L27
12,285
andywer/webpack-blocks
packages/core/lib/createConfig.js
createConfig
function createConfig(initialContext, configSetters) { if (!initialContext) { throw new Error(`No initial context passed.`) } assertConfigSetters(configSetters) const baseConfig = { resolve: { // Explicitly define default extensions, otherwise blocks will overwrite them instead of extending ...
javascript
function createConfig(initialContext, configSetters) { if (!initialContext) { throw new Error(`No initial context passed.`) } assertConfigSetters(configSetters) const baseConfig = { resolve: { // Explicitly define default extensions, otherwise blocks will overwrite them instead of extending ...
[ "function", "createConfig", "(", "initialContext", ",", "configSetters", ")", "{", "if", "(", "!", "initialContext", ")", "{", "throw", "new", "Error", "(", "`", "`", ")", "}", "assertConfigSetters", "(", "configSetters", ")", "const", "baseConfig", "=", "{"...
Takes an array of webpack blocks and creates a webpack config out of them. Each webpack block is a callback function which will be invoked to return a partial webpack config. These partial configs are merged to create the final, complete webpack config that will be returned. @param {object} initialContext ...
[ "Takes", "an", "array", "of", "webpack", "blocks", "and", "creates", "a", "webpack", "config", "out", "of", "them", ".", "Each", "webpack", "block", "is", "a", "callback", "function", "which", "will", "be", "invoked", "to", "return", "a", "partial", "webpa...
dca0f219a6551b727494a53e043f87694422a546
https://github.com/andywer/webpack-blocks/blob/dca0f219a6551b727494a53e043f87694422a546/packages/core/lib/createConfig.js#L18-L47
12,286
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
ngSwaggerGen
function ngSwaggerGen(options) { if (typeof options.swagger != 'string') { console.error("Swagger file not specified in the 'swagger' option"); process.exit(1); } var globalTunnel = require('global-tunnel-ng'); globalTunnel.initialize(); $RefParser.bundle(options.swagger, { dereference: { circular...
javascript
function ngSwaggerGen(options) { if (typeof options.swagger != 'string') { console.error("Swagger file not specified in the 'swagger' option"); process.exit(1); } var globalTunnel = require('global-tunnel-ng'); globalTunnel.initialize(); $RefParser.bundle(options.swagger, { dereference: { circular...
[ "function", "ngSwaggerGen", "(", "options", ")", "{", "if", "(", "typeof", "options", ".", "swagger", "!=", "'string'", ")", "{", "console", ".", "error", "(", "\"Swagger file not specified in the 'swagger' option\"", ")", ";", "process", ".", "exit", "(", "1", ...
Main generate function
[ "Main", "generate", "function" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L14-L35
12,287
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
function(template, model, file) { var code = Mustache.render(template, model, templates) .replace(/[^\S\r\n]+$/gm, ''); fs.writeFileSync(file, code, 'UTF-8'); console.info('Wrote ' + file); }
javascript
function(template, model, file) { var code = Mustache.render(template, model, templates) .replace(/[^\S\r\n]+$/gm, ''); fs.writeFileSync(file, code, 'UTF-8'); console.info('Wrote ' + file); }
[ "function", "(", "template", ",", "model", ",", "file", ")", "{", "var", "code", "=", "Mustache", ".", "render", "(", "template", ",", "model", ",", "templates", ")", ".", "replace", "(", "/", "[^\\S\\r\\n]+$", "/", "gm", ",", "''", ")", ";", "fs", ...
Utility function to render a template and write it to a file
[ "Utility", "function", "to", "render", "a", "template", "and", "write", "it", "to", "a", "file" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L93-L98
12,288
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
applyTagFilter
function applyTagFilter(models, services, options) { var i; // Normalize the included tag names const includeTags = options.includeTags; var included = null; if (includeTags && includeTags.length > 0) { included = []; for (i = 0; i < includeTags.length; i++) { included.push(tagName(includeTags[i...
javascript
function applyTagFilter(models, services, options) { var i; // Normalize the included tag names const includeTags = options.includeTags; var included = null; if (includeTags && includeTags.length > 0) { included = []; for (i = 0; i < includeTags.length; i++) { included.push(tagName(includeTags[i...
[ "function", "applyTagFilter", "(", "models", ",", "services", ",", "options", ")", "{", "var", "i", ";", "// Normalize the included tag names", "const", "includeTags", "=", "options", ".", "includeTags", ";", "var", "included", "=", "null", ";", "if", "(", "in...
Applies a filter over the given services, keeping only the specific tags. Also optionally removes any unused models, even services are filtered.
[ "Applies", "a", "filter", "over", "the", "given", "services", "keeping", "only", "the", "specific", "tags", ".", "Also", "optionally", "removes", "any", "unused", "models", "even", "services", "are", "filtered", "." ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L272-L335
12,289
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
collectDependencies
function collectDependencies(dependencies, model, models) { if (!model || dependencies.has(model.modelClass)) { return; } dependencies.add(model.modelClass); if (model.modelDependencies) { model.modelDependencies.forEach((dep) => collectDependencies(dependencies, dep, models) ); } }
javascript
function collectDependencies(dependencies, model, models) { if (!model || dependencies.has(model.modelClass)) { return; } dependencies.add(model.modelClass); if (model.modelDependencies) { model.modelDependencies.forEach((dep) => collectDependencies(dependencies, dep, models) ); } }
[ "function", "collectDependencies", "(", "dependencies", ",", "model", ",", "models", ")", "{", "if", "(", "!", "model", "||", "dependencies", ".", "has", "(", "model", ".", "modelClass", ")", ")", "{", "return", ";", "}", "dependencies", ".", "add", "(",...
Collects on the given dependencies set all dependencies of the given model
[ "Collects", "on", "the", "given", "dependencies", "set", "all", "dependencies", "of", "the", "given", "model" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L340-L350
12,290
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
toFileName
function toFileName(typeName) { var result = ''; var wasLower = false; for (var i = 0; i < typeName.length; i++) { var c = typeName.charAt(i); var isLower = /[a-z]/.test(c); if (!isLower && wasLower) { result += '-'; } result += c.toLowerCase(); wasLower = isLower; } return resul...
javascript
function toFileName(typeName) { var result = ''; var wasLower = false; for (var i = 0; i < typeName.length; i++) { var c = typeName.charAt(i); var isLower = /[a-z]/.test(c); if (!isLower && wasLower) { result += '-'; } result += c.toLowerCase(); wasLower = isLower; } return resul...
[ "function", "toFileName", "(", "typeName", ")", "{", "var", "result", "=", "''", ";", "var", "wasLower", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "typeName", ".", "length", ";", "i", "++", ")", "{", "var", "c", "=", "...
Converts a given type name into a TS file name
[ "Converts", "a", "given", "type", "name", "into", "a", "TS", "file", "name" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L384-L397
12,291
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
toClassName
function toClassName(name) { var result = ''; var upNext = false; for (var i = 0; i < name.length; i++) { var c = name.charAt(i); var valid = /[\w]/.test(c); if (!valid) { upNext = true; } else if (upNext) { result += c.toUpperCase(); upNext = false; } else if (result === '')...
javascript
function toClassName(name) { var result = ''; var upNext = false; for (var i = 0; i < name.length; i++) { var c = name.charAt(i); var valid = /[\w]/.test(c); if (!valid) { upNext = true; } else if (upNext) { result += c.toUpperCase(); upNext = false; } else if (result === '')...
[ "function", "toClassName", "(", "name", ")", "{", "var", "result", "=", "''", ";", "var", "upNext", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "name", ".", "length", ";", "i", "++", ")", "{", "var", "c", "=", "name", ...
Converts a given name into a valid class name
[ "Converts", "a", "given", "name", "into", "a", "valid", "class", "name" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L402-L423
12,292
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
simpleRef
function simpleRef(ref) { if (!ref) { return null; } var index = ref.lastIndexOf('/'); if (index >= 0) { ref = ref.substr(index + 1); } return toClassName(ref); }
javascript
function simpleRef(ref) { if (!ref) { return null; } var index = ref.lastIndexOf('/'); if (index >= 0) { ref = ref.substr(index + 1); } return toClassName(ref); }
[ "function", "simpleRef", "(", "ref", ")", "{", "if", "(", "!", "ref", ")", "{", "return", "null", ";", "}", "var", "index", "=", "ref", ".", "lastIndexOf", "(", "'/'", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "ref", "=", "ref", ".", ...
Resolves the simple reference name from a qualified reference
[ "Resolves", "the", "simple", "reference", "name", "from", "a", "qualified", "reference" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L436-L445
12,293
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
toEnumName
function toEnumName(value) { var result = ''; var wasLower = false; for (var i = 0; i < value.length; i++) { var c = value.charAt(i); var isLower = /[a-z]/.test(c); if (!isLower && wasLower) { result += '_'; } result += c.toUpperCase(); wasLower = isLower; } if (!isNaN(value[0]))...
javascript
function toEnumName(value) { var result = ''; var wasLower = false; for (var i = 0; i < value.length; i++) { var c = value.charAt(i); var isLower = /[a-z]/.test(c); if (!isLower && wasLower) { result += '_'; } result += c.toUpperCase(); wasLower = isLower; } if (!isNaN(value[0]))...
[ "function", "toEnumName", "(", "value", ")", "{", "var", "result", "=", "''", ";", "var", "wasLower", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "value", ".", "length", ";", "i", "++", ")", "{", "var", "c", "=", "value"...
Converts a given enum value into the enum name
[ "Converts", "a", "given", "enum", "value", "into", "the", "enum", "name" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L450-L468
12,294
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
toComments
function toComments(text, level) { var indent = ''; var i; for (i = 0; i < level; i++) { indent += ' '; } if (text == null || text.length === 0) { return indent; } const lines = text.trim().split('\n'); var result = '\n' + indent + '/**\n'; lines.forEach(line => { result += indent + ' *' ...
javascript
function toComments(text, level) { var indent = ''; var i; for (i = 0; i < level; i++) { indent += ' '; } if (text == null || text.length === 0) { return indent; } const lines = text.trim().split('\n'); var result = '\n' + indent + '/**\n'; lines.forEach(line => { result += indent + ' *' ...
[ "function", "toComments", "(", "text", ",", "level", ")", "{", "var", "indent", "=", "''", ";", "var", "i", ";", "for", "(", "i", "=", "0", ";", "i", "<", "level", ";", "i", "++", ")", "{", "indent", "+=", "' '", ";", "}", "if", "(", "text",...
Returns a multi-line comment for the given text
[ "Returns", "a", "multi", "-", "line", "comment", "for", "the", "given", "text" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L473-L489
12,295
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
mergeTypes
function mergeTypes(...types) { let allTypes = []; types.forEach(type => { (type.allTypes || [type]).forEach(type => { if (allTypes.indexOf(type) < 0) allTypes.push(type); }); }); return allTypes; }
javascript
function mergeTypes(...types) { let allTypes = []; types.forEach(type => { (type.allTypes || [type]).forEach(type => { if (allTypes.indexOf(type) < 0) allTypes.push(type); }); }); return allTypes; }
[ "function", "mergeTypes", "(", "...", "types", ")", "{", "let", "allTypes", "=", "[", "]", ";", "types", ".", "forEach", "(", "type", "=>", "{", "(", "type", ".", "allTypes", "||", "[", "type", "]", ")", ".", "forEach", "(", "type", "=>", "{", "i...
Combine dependencies of multiple types. @param types @return {Array}
[ "Combine", "dependencies", "of", "multiple", "types", "." ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L724-L732
12,296
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
processProperties
function processProperties(swagger, properties, requiredProperties) { var result = {}; for (var name in properties) { var property = properties[name]; var descriptor = { propertyName: name.indexOf('-') === -1 ? name : `"${name}"`, propertyComments: toComments(property.description, 1), prop...
javascript
function processProperties(swagger, properties, requiredProperties) { var result = {}; for (var name in properties) { var property = properties[name]; var descriptor = { propertyName: name.indexOf('-') === -1 ? name : `"${name}"`, propertyComments: toComments(property.description, 1), prop...
[ "function", "processProperties", "(", "swagger", ",", "properties", ",", "requiredProperties", ")", "{", "var", "result", "=", "{", "}", ";", "for", "(", "var", "name", "in", "properties", ")", "{", "var", "property", "=", "properties", "[", "name", "]", ...
Process each property for the given properties object, returning an object keyed by property name with simplified property types
[ "Process", "each", "property", "for", "the", "given", "properties", "object", "returning", "an", "object", "keyed", "by", "property", "name", "with", "simplified", "property", "types" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L841-L854
12,297
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
resolveRef
function resolveRef(swagger, ref) { if (ref.indexOf('#/') != 0) { console.error('Resolved references must start with #/. Current: ' + ref); process.exit(1); } var parts = ref.substr(2).split('/'); var result = swagger; for (var i = 0; i < parts.length; i++) { var part = parts[i]; result = resu...
javascript
function resolveRef(swagger, ref) { if (ref.indexOf('#/') != 0) { console.error('Resolved references must start with #/. Current: ' + ref); process.exit(1); } var parts = ref.substr(2).split('/'); var result = swagger; for (var i = 0; i < parts.length; i++) { var part = parts[i]; result = resu...
[ "function", "resolveRef", "(", "swagger", ",", "ref", ")", "{", "if", "(", "ref", ".", "indexOf", "(", "'#/'", ")", "!=", "0", ")", "{", "console", ".", "error", "(", "'Resolved references must start with #/. Current: '", "+", "ref", ")", ";", "process", "...
Resolves a local reference in the given swagger file
[ "Resolves", "a", "local", "reference", "in", "the", "given", "swagger", "file" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L859-L871
12,298
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
toIdentifier
function toIdentifier(string) { var result = ''; var wasSep = false; for (var i = 0; i < string.length; i++) { var c = string.charAt(i); if (/[a-zA-Z0-9]/.test(c)) { if (wasSep) { c = c.toUpperCase(); wasSep = false; } result += c; } else { wasSep = true; } ...
javascript
function toIdentifier(string) { var result = ''; var wasSep = false; for (var i = 0; i < string.length; i++) { var c = string.charAt(i); if (/[a-zA-Z0-9]/.test(c)) { if (wasSep) { c = c.toUpperCase(); wasSep = false; } result += c; } else { wasSep = true; } ...
[ "function", "toIdentifier", "(", "string", ")", "{", "var", "result", "=", "''", ";", "var", "wasSep", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "string", ".", "length", ";", "i", "++", ")", "{", "var", "c", "=", "stri...
Transforms the given string into a valid identifier
[ "Transforms", "the", "given", "string", "into", "a", "valid", "identifier" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L931-L947
12,299
cyclosproject/ng-swagger-gen
ng-swagger-gen.js
tagName
function tagName(tag, options) { if (tag == null || tag === '') { tag = options.defaultTag || 'Api'; } tag = toIdentifier(tag); return tag.charAt(0).toUpperCase() + (tag.length == 1 ? '' : tag.substr(1)); }
javascript
function tagName(tag, options) { if (tag == null || tag === '') { tag = options.defaultTag || 'Api'; } tag = toIdentifier(tag); return tag.charAt(0).toUpperCase() + (tag.length == 1 ? '' : tag.substr(1)); }
[ "function", "tagName", "(", "tag", ",", "options", ")", "{", "if", "(", "tag", "==", "null", "||", "tag", "===", "''", ")", "{", "tag", "=", "options", ".", "defaultTag", "||", "'Api'", ";", "}", "tag", "=", "toIdentifier", "(", "tag", ")", ";", ...
Normalizes the tag name. Actually, capitalizes the given name. If the given tag is null, returns the default from options
[ "Normalizes", "the", "tag", "name", ".", "Actually", "capitalizes", "the", "given", "name", ".", "If", "the", "given", "tag", "is", "null", "returns", "the", "default", "from", "options" ]
64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb
https://github.com/cyclosproject/ng-swagger-gen/blob/64fa7bab50a6ceb2b7ffd610498c97bc1377c9fb/ng-swagger-gen.js#L953-L959