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
37,500
jimivdw/grunt-mutation-testing
lib/reporting/html/HtmlReporter.js
function(basePath, config) { this._basePath = basePath; this._config = config; var directories = IOUtils.getDirectoryList(basePath, false); IOUtils.createPathIfNotExists(directories, './'); }
javascript
function(basePath, config) { this._basePath = basePath; this._config = config; var directories = IOUtils.getDirectoryList(basePath, false); IOUtils.createPathIfNotExists(directories, './'); }
[ "function", "(", "basePath", ",", "config", ")", "{", "this", ".", "_basePath", "=", "basePath", ";", "this", ".", "_config", "=", "config", ";", "var", "directories", "=", "IOUtils", ".", "getDirectoryList", "(", "basePath", ",", "false", ")", ";", "IOUtils", ".", "createPathIfNotExists", "(", "directories", ",", "'./'", ")", ";", "}" ]
Constructor for the HTML reporter. @param {string} basePath The base path where the report should be created @param {object=} config Configuration object @constructor
[ "Constructor", "for", "the", "HTML", "reporter", "." ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/reporting/html/HtmlReporter.js#L29-L35
37,501
infrabel/themes-gnap
raw/angular-dynamic-locale/tmhDynamicLocale.js
loadScript
function loadScript(url, callback, errorCallback, $timeout) { var script = document.createElement('script'), body = document.getElementsByTagName('body')[0], removed = false; script.type = 'text/javascript'; if (script.readyState) { // IE script.onreadystatechange = function () { if (script.readyState === 'complete' || script.readyState === 'loaded') { script.onreadystatechange = null; $timeout( function () { if (removed) return; removed = true; body.removeChild(script); callback(); }, 30, false); } }; } else { // Others script.onload = function () { if (removed) return; removed = true; body.removeChild(script); callback(); }; script.onerror = function () { if (removed) return; removed = true; body.removeChild(script); errorCallback(); }; } script.src = url; script.async = false; body.appendChild(script); }
javascript
function loadScript(url, callback, errorCallback, $timeout) { var script = document.createElement('script'), body = document.getElementsByTagName('body')[0], removed = false; script.type = 'text/javascript'; if (script.readyState) { // IE script.onreadystatechange = function () { if (script.readyState === 'complete' || script.readyState === 'loaded') { script.onreadystatechange = null; $timeout( function () { if (removed) return; removed = true; body.removeChild(script); callback(); }, 30, false); } }; } else { // Others script.onload = function () { if (removed) return; removed = true; body.removeChild(script); callback(); }; script.onerror = function () { if (removed) return; removed = true; body.removeChild(script); errorCallback(); }; } script.src = url; script.async = false; body.appendChild(script); }
[ "function", "loadScript", "(", "url", ",", "callback", ",", "errorCallback", ",", "$timeout", ")", "{", "var", "script", "=", "document", ".", "createElement", "(", "'script'", ")", ",", "body", "=", "document", ".", "getElementsByTagName", "(", "'body'", ")", "[", "0", "]", ",", "removed", "=", "false", ";", "script", ".", "type", "=", "'text/javascript'", ";", "if", "(", "script", ".", "readyState", ")", "{", "// IE", "script", ".", "onreadystatechange", "=", "function", "(", ")", "{", "if", "(", "script", ".", "readyState", "===", "'complete'", "||", "script", ".", "readyState", "===", "'loaded'", ")", "{", "script", ".", "onreadystatechange", "=", "null", ";", "$timeout", "(", "function", "(", ")", "{", "if", "(", "removed", ")", "return", ";", "removed", "=", "true", ";", "body", ".", "removeChild", "(", "script", ")", ";", "callback", "(", ")", ";", "}", ",", "30", ",", "false", ")", ";", "}", "}", ";", "}", "else", "{", "// Others", "script", ".", "onload", "=", "function", "(", ")", "{", "if", "(", "removed", ")", "return", ";", "removed", "=", "true", ";", "body", ".", "removeChild", "(", "script", ")", ";", "callback", "(", ")", ";", "}", ";", "script", ".", "onerror", "=", "function", "(", ")", "{", "if", "(", "removed", ")", "return", ";", "removed", "=", "true", ";", "body", ".", "removeChild", "(", "script", ")", ";", "errorCallback", "(", ")", ";", "}", ";", "}", "script", ".", "src", "=", "url", ";", "script", ".", "async", "=", "false", ";", "body", ".", "appendChild", "(", "script", ")", ";", "}" ]
Loads a script asynchronously @param {string} url The url for the script @ @param {function) callback A function to be called once the script is loaded
[ "Loads", "a", "script", "asynchronously" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/angular-dynamic-locale/tmhDynamicLocale.js#L19-L56
37,502
infrabel/themes-gnap
raw/angular-dynamic-locale/tmhDynamicLocale.js
loadLocale
function loadLocale(localeUrl, $locale, localeId, $rootScope, $q, localeCache, $timeout) { function overrideValues(oldObject, newObject) { if (activeLocale !== localeId) { return; } angular.forEach(oldObject, function(value, key) { if (!newObject[key]) { delete oldObject[key]; } else if (angular.isArray(newObject[key])) { oldObject[key].length = newObject[key].length; } }); angular.forEach(newObject, function(value, key) { if (angular.isArray(newObject[key]) || angular.isObject(newObject[key])) { if (!oldObject[key]) { oldObject[key] = angular.isArray(newObject[key]) ? [] : {}; } overrideValues(oldObject[key], newObject[key]); } else { oldObject[key] = newObject[key]; } }); } if (promiseCache[localeId]) return promiseCache[localeId]; var cachedLocale, deferred = $q.defer(); if (localeId === activeLocale) { deferred.resolve($locale); } else if ((cachedLocale = localeCache.get(localeId))) { activeLocale = localeId; $rootScope.$evalAsync(function() { overrideValues($locale, cachedLocale); $rootScope.$broadcast('$localeChangeSuccess', localeId, $locale); storage.put(storeKey, localeId); deferred.resolve($locale); }); } else { activeLocale = localeId; promiseCache[localeId] = deferred.promise; loadScript(localeUrl, function () { // Create a new injector with the new locale var localInjector = angular.injector(['ngLocale']), externalLocale = localInjector.get('$locale'); overrideValues($locale, externalLocale); localeCache.put(localeId, externalLocale); delete promiseCache[localeId]; $rootScope.$apply(function () { $rootScope.$broadcast('$localeChangeSuccess', localeId, $locale); storage.put(storeKey, localeId); deferred.resolve($locale); }); }, function () { delete promiseCache[localeId]; $rootScope.$apply(function () { $rootScope.$broadcast('$localeChangeError', localeId); deferred.reject(localeId); }); }, $timeout); } return deferred.promise; }
javascript
function loadLocale(localeUrl, $locale, localeId, $rootScope, $q, localeCache, $timeout) { function overrideValues(oldObject, newObject) { if (activeLocale !== localeId) { return; } angular.forEach(oldObject, function(value, key) { if (!newObject[key]) { delete oldObject[key]; } else if (angular.isArray(newObject[key])) { oldObject[key].length = newObject[key].length; } }); angular.forEach(newObject, function(value, key) { if (angular.isArray(newObject[key]) || angular.isObject(newObject[key])) { if (!oldObject[key]) { oldObject[key] = angular.isArray(newObject[key]) ? [] : {}; } overrideValues(oldObject[key], newObject[key]); } else { oldObject[key] = newObject[key]; } }); } if (promiseCache[localeId]) return promiseCache[localeId]; var cachedLocale, deferred = $q.defer(); if (localeId === activeLocale) { deferred.resolve($locale); } else if ((cachedLocale = localeCache.get(localeId))) { activeLocale = localeId; $rootScope.$evalAsync(function() { overrideValues($locale, cachedLocale); $rootScope.$broadcast('$localeChangeSuccess', localeId, $locale); storage.put(storeKey, localeId); deferred.resolve($locale); }); } else { activeLocale = localeId; promiseCache[localeId] = deferred.promise; loadScript(localeUrl, function () { // Create a new injector with the new locale var localInjector = angular.injector(['ngLocale']), externalLocale = localInjector.get('$locale'); overrideValues($locale, externalLocale); localeCache.put(localeId, externalLocale); delete promiseCache[localeId]; $rootScope.$apply(function () { $rootScope.$broadcast('$localeChangeSuccess', localeId, $locale); storage.put(storeKey, localeId); deferred.resolve($locale); }); }, function () { delete promiseCache[localeId]; $rootScope.$apply(function () { $rootScope.$broadcast('$localeChangeError', localeId); deferred.reject(localeId); }); }, $timeout); } return deferred.promise; }
[ "function", "loadLocale", "(", "localeUrl", ",", "$locale", ",", "localeId", ",", "$rootScope", ",", "$q", ",", "localeCache", ",", "$timeout", ")", "{", "function", "overrideValues", "(", "oldObject", ",", "newObject", ")", "{", "if", "(", "activeLocale", "!==", "localeId", ")", "{", "return", ";", "}", "angular", ".", "forEach", "(", "oldObject", ",", "function", "(", "value", ",", "key", ")", "{", "if", "(", "!", "newObject", "[", "key", "]", ")", "{", "delete", "oldObject", "[", "key", "]", ";", "}", "else", "if", "(", "angular", ".", "isArray", "(", "newObject", "[", "key", "]", ")", ")", "{", "oldObject", "[", "key", "]", ".", "length", "=", "newObject", "[", "key", "]", ".", "length", ";", "}", "}", ")", ";", "angular", ".", "forEach", "(", "newObject", ",", "function", "(", "value", ",", "key", ")", "{", "if", "(", "angular", ".", "isArray", "(", "newObject", "[", "key", "]", ")", "||", "angular", ".", "isObject", "(", "newObject", "[", "key", "]", ")", ")", "{", "if", "(", "!", "oldObject", "[", "key", "]", ")", "{", "oldObject", "[", "key", "]", "=", "angular", ".", "isArray", "(", "newObject", "[", "key", "]", ")", "?", "[", "]", ":", "{", "}", ";", "}", "overrideValues", "(", "oldObject", "[", "key", "]", ",", "newObject", "[", "key", "]", ")", ";", "}", "else", "{", "oldObject", "[", "key", "]", "=", "newObject", "[", "key", "]", ";", "}", "}", ")", ";", "}", "if", "(", "promiseCache", "[", "localeId", "]", ")", "return", "promiseCache", "[", "localeId", "]", ";", "var", "cachedLocale", ",", "deferred", "=", "$q", ".", "defer", "(", ")", ";", "if", "(", "localeId", "===", "activeLocale", ")", "{", "deferred", ".", "resolve", "(", "$locale", ")", ";", "}", "else", "if", "(", "(", "cachedLocale", "=", "localeCache", ".", "get", "(", "localeId", ")", ")", ")", "{", "activeLocale", "=", "localeId", ";", "$rootScope", ".", "$evalAsync", "(", "function", "(", ")", "{", "overrideValues", "(", "$locale", ",", "cachedLocale", ")", ";", "$rootScope", ".", "$broadcast", "(", "'$localeChangeSuccess'", ",", "localeId", ",", "$locale", ")", ";", "storage", ".", "put", "(", "storeKey", ",", "localeId", ")", ";", "deferred", ".", "resolve", "(", "$locale", ")", ";", "}", ")", ";", "}", "else", "{", "activeLocale", "=", "localeId", ";", "promiseCache", "[", "localeId", "]", "=", "deferred", ".", "promise", ";", "loadScript", "(", "localeUrl", ",", "function", "(", ")", "{", "// Create a new injector with the new locale", "var", "localInjector", "=", "angular", ".", "injector", "(", "[", "'ngLocale'", "]", ")", ",", "externalLocale", "=", "localInjector", ".", "get", "(", "'$locale'", ")", ";", "overrideValues", "(", "$locale", ",", "externalLocale", ")", ";", "localeCache", ".", "put", "(", "localeId", ",", "externalLocale", ")", ";", "delete", "promiseCache", "[", "localeId", "]", ";", "$rootScope", ".", "$apply", "(", "function", "(", ")", "{", "$rootScope", ".", "$broadcast", "(", "'$localeChangeSuccess'", ",", "localeId", ",", "$locale", ")", ";", "storage", ".", "put", "(", "storeKey", ",", "localeId", ")", ";", "deferred", ".", "resolve", "(", "$locale", ")", ";", "}", ")", ";", "}", ",", "function", "(", ")", "{", "delete", "promiseCache", "[", "localeId", "]", ";", "$rootScope", ".", "$apply", "(", "function", "(", ")", "{", "$rootScope", ".", "$broadcast", "(", "'$localeChangeError'", ",", "localeId", ")", ";", "deferred", ".", "reject", "(", "localeId", ")", ";", "}", ")", ";", "}", ",", "$timeout", ")", ";", "}", "return", "deferred", ".", "promise", ";", "}" ]
Loads a locale and replaces the properties from the current locale with the new locale information @param localeUrl The path to the new locale @param $locale The locale at the curent scope
[ "Loads", "a", "locale", "and", "replaces", "the", "properties", "from", "the", "current", "locale", "with", "the", "new", "locale", "information" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/angular-dynamic-locale/tmhDynamicLocale.js#L64-L131
37,503
kenahrens/newrelic-api-client-js
scripts/get-expirations.js
outputFile
function outputFile(configId, outputdata){ var fname= configId+ '_accounts.csv'; console.log("Outputing file... "+fname); var input= { data: outputdata, fields: ['id','name','status','subscriptionStarts','subscriptionExpires'] }; json2csv(input, function(err, csv) { if (err) { console.log('ERROR!'); console.log(err); } else { fs.writeFileSync(fname,csv); } }); }
javascript
function outputFile(configId, outputdata){ var fname= configId+ '_accounts.csv'; console.log("Outputing file... "+fname); var input= { data: outputdata, fields: ['id','name','status','subscriptionStarts','subscriptionExpires'] }; json2csv(input, function(err, csv) { if (err) { console.log('ERROR!'); console.log(err); } else { fs.writeFileSync(fname,csv); } }); }
[ "function", "outputFile", "(", "configId", ",", "outputdata", ")", "{", "var", "fname", "=", "configId", "+", "'_accounts.csv'", ";", "console", ".", "log", "(", "\"Outputing file... \"", "+", "fname", ")", ";", "var", "input", "=", "{", "data", ":", "outputdata", ",", "fields", ":", "[", "'id'", ",", "'name'", ",", "'status'", ",", "'subscriptionStarts'", ",", "'subscriptionExpires'", "]", "}", ";", "json2csv", "(", "input", ",", "function", "(", "err", ",", "csv", ")", "{", "if", "(", "err", ")", "{", "console", ".", "log", "(", "'ERROR!'", ")", ";", "console", ".", "log", "(", "err", ")", ";", "}", "else", "{", "fs", ".", "writeFileSync", "(", "fname", ",", "csv", ")", ";", "}", "}", ")", ";", "}" ]
Get all the accounts and apikeys for a partner account, output as CSV Write the output file
[ "Get", "all", "the", "accounts", "and", "apikeys", "for", "a", "partner", "account", "output", "as", "CSV", "Write", "the", "output", "file" ]
0776c66e3959ab489f600c16dba4ec9f62f99d2a
https://github.com/kenahrens/newrelic-api-client-js/blob/0776c66e3959ab489f600c16dba4ec9f62f99d2a/scripts/get-expirations.js#L14-L29
37,504
RoganMurley/hitagi.js
src/utils.js
function (originalObj, originalProp, targetObj, targetProp) { Object.defineProperty( originalObj, originalProp, { get: function () { return targetObj[targetProp]; }, set: function (newValue) { targetObj[targetProp] = newValue; } } ); }
javascript
function (originalObj, originalProp, targetObj, targetProp) { Object.defineProperty( originalObj, originalProp, { get: function () { return targetObj[targetProp]; }, set: function (newValue) { targetObj[targetProp] = newValue; } } ); }
[ "function", "(", "originalObj", ",", "originalProp", ",", "targetObj", ",", "targetProp", ")", "{", "Object", ".", "defineProperty", "(", "originalObj", ",", "originalProp", ",", "{", "get", ":", "function", "(", ")", "{", "return", "targetObj", "[", "targetProp", "]", ";", "}", ",", "set", ":", "function", "(", "newValue", ")", "{", "targetObj", "[", "targetProp", "]", "=", "newValue", ";", "}", "}", ")", ";", "}" ]
Proxy a property, simillar to the proxy in ES6. Allows us to propagate changes to the target property.
[ "Proxy", "a", "property", "simillar", "to", "the", "proxy", "in", "ES6", ".", "Allows", "us", "to", "propagate", "changes", "to", "the", "target", "property", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/src/utils.js#L17-L30
37,505
RoganMurley/hitagi.js
src/utils.js
function (originalObj, originalProp, targetObj, targetProp) { Object.defineProperty( originalObj, originalProp, { get: function () { return targetObj[targetProp]; }, set: function (newValue) { console.error(targetProp + ' is read-only.'); throw new Error('ReadOnly'); } } ); }
javascript
function (originalObj, originalProp, targetObj, targetProp) { Object.defineProperty( originalObj, originalProp, { get: function () { return targetObj[targetProp]; }, set: function (newValue) { console.error(targetProp + ' is read-only.'); throw new Error('ReadOnly'); } } ); }
[ "function", "(", "originalObj", ",", "originalProp", ",", "targetObj", ",", "targetProp", ")", "{", "Object", ".", "defineProperty", "(", "originalObj", ",", "originalProp", ",", "{", "get", ":", "function", "(", ")", "{", "return", "targetObj", "[", "targetProp", "]", ";", "}", ",", "set", ":", "function", "(", "newValue", ")", "{", "console", ".", "error", "(", "targetProp", "+", "' is read-only.'", ")", ";", "throw", "new", "Error", "(", "'ReadOnly'", ")", ";", "}", "}", ")", ";", "}" ]
A read-only version of proxy, see above.
[ "A", "read", "-", "only", "version", "of", "proxy", "see", "above", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/src/utils.js#L34-L48
37,506
RoganMurley/hitagi.js
src/utils.js
function (obj, prop, callback, callbackParams) { var value = obj[prop]; Object.defineProperty( obj, prop, { get: function () { return value; }, set: function (newValue) { value = newValue; callback(newValue, callbackParams); } } ); }
javascript
function (obj, prop, callback, callbackParams) { var value = obj[prop]; Object.defineProperty( obj, prop, { get: function () { return value; }, set: function (newValue) { value = newValue; callback(newValue, callbackParams); } } ); }
[ "function", "(", "obj", ",", "prop", ",", "callback", ",", "callbackParams", ")", "{", "var", "value", "=", "obj", "[", "prop", "]", ";", "Object", ".", "defineProperty", "(", "obj", ",", "prop", ",", "{", "get", ":", "function", "(", ")", "{", "return", "value", ";", "}", ",", "set", ":", "function", "(", "newValue", ")", "{", "value", "=", "newValue", ";", "callback", "(", "newValue", ",", "callbackParams", ")", ";", "}", "}", ")", ";", "}" ]
Watches a property, executing a callback when the property changes.
[ "Watches", "a", "property", "executing", "a", "callback", "when", "the", "property", "changes", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/src/utils.js#L52-L68
37,507
kenahrens/newrelic-api-client-js
scripts/dashboard-from-json.js
function(error, response, body) { var rspBody = helper.handleCB(error, response, body); if (rspBody != null) { var destId = config.get(program.dest).accountId; var url = 'http://insights.newrelic.com/accounts/' + destId + '/dashboards/' + rspBody.dashboard.id; console.log('Dashboard created: ' + url); } }
javascript
function(error, response, body) { var rspBody = helper.handleCB(error, response, body); if (rspBody != null) { var destId = config.get(program.dest).accountId; var url = 'http://insights.newrelic.com/accounts/' + destId + '/dashboards/' + rspBody.dashboard.id; console.log('Dashboard created: ' + url); } }
[ "function", "(", "error", ",", "response", ",", "body", ")", "{", "var", "rspBody", "=", "helper", ".", "handleCB", "(", "error", ",", "response", ",", "body", ")", ";", "if", "(", "rspBody", "!=", "null", ")", "{", "var", "destId", "=", "config", ".", "get", "(", "program", ".", "dest", ")", ".", "accountId", ";", "var", "url", "=", "'http://insights.newrelic.com/accounts/'", "+", "destId", "+", "'/dashboards/'", "+", "rspBody", ".", "dashboard", ".", "id", ";", "console", ".", "log", "(", "'Dashboard created: '", "+", "url", ")", ";", "}", "}" ]
Print out the URL of the newly created dashboard
[ "Print", "out", "the", "URL", "of", "the", "newly", "created", "dashboard" ]
0776c66e3959ab489f600c16dba4ec9f62f99d2a
https://github.com/kenahrens/newrelic-api-client-js/blob/0776c66e3959ab489f600c16dba4ec9f62f99d2a/scripts/dashboard-from-json.js#L8-L15
37,508
kenahrens/newrelic-api-client-js
scripts/dashboard-from-json.js
readDashFromFS
function readDashFromFS(fname) { var dashboardBody = fs.readFileSync(fname); console.log('Read file:', fname); // Set the proper account_id on all widgets if (dashboardBody != null) { dashboardBody = JSON.parse(dashboardBody); console.log('Read source dashboard named: ' + dashboardBody.dashboard.title); var destId = config.get(program.dest).accountId; dashboardBody = dashboards.updateAccountId(dashboardBody, 1, destId); console.log(dashboardBody); } else { console.error('Problem reading file', fname); } return dashboardBody; }
javascript
function readDashFromFS(fname) { var dashboardBody = fs.readFileSync(fname); console.log('Read file:', fname); // Set the proper account_id on all widgets if (dashboardBody != null) { dashboardBody = JSON.parse(dashboardBody); console.log('Read source dashboard named: ' + dashboardBody.dashboard.title); var destId = config.get(program.dest).accountId; dashboardBody = dashboards.updateAccountId(dashboardBody, 1, destId); console.log(dashboardBody); } else { console.error('Problem reading file', fname); } return dashboardBody; }
[ "function", "readDashFromFS", "(", "fname", ")", "{", "var", "dashboardBody", "=", "fs", ".", "readFileSync", "(", "fname", ")", ";", "console", ".", "log", "(", "'Read file:'", ",", "fname", ")", ";", "// Set the proper account_id on all widgets", "if", "(", "dashboardBody", "!=", "null", ")", "{", "dashboardBody", "=", "JSON", ".", "parse", "(", "dashboardBody", ")", ";", "console", ".", "log", "(", "'Read source dashboard named: '", "+", "dashboardBody", ".", "dashboard", ".", "title", ")", ";", "var", "destId", "=", "config", ".", "get", "(", "program", ".", "dest", ")", ".", "accountId", ";", "dashboardBody", "=", "dashboards", ".", "updateAccountId", "(", "dashboardBody", ",", "1", ",", "destId", ")", ";", "console", ".", "log", "(", "dashboardBody", ")", ";", "}", "else", "{", "console", ".", "error", "(", "'Problem reading file'", ",", "fname", ")", ";", "}", "return", "dashboardBody", ";", "}" ]
Read the source dashboard from the file system
[ "Read", "the", "source", "dashboard", "from", "the", "file", "system" ]
0776c66e3959ab489f600c16dba4ec9f62f99d2a
https://github.com/kenahrens/newrelic-api-client-js/blob/0776c66e3959ab489f600c16dba4ec9f62f99d2a/scripts/dashboard-from-json.js#L18-L36
37,509
dominicbarnes/node-couchdb-api
docs/render.js
function (done) { glob(path.join(__dirname, "*.ejs"), function (err, files) { if (err) { return done(err); } var templates = {}; async.forEach(files, function (file, done) { fs.readFile(file, "utf8", function (err, data) { if (err) { return done(err); } else { templates[path.basename(file, ".ejs")] = _.template(data); done(); } }); }, function (err) { if (err) { return done(err); } done(null, templates); }); }); }
javascript
function (done) { glob(path.join(__dirname, "*.ejs"), function (err, files) { if (err) { return done(err); } var templates = {}; async.forEach(files, function (file, done) { fs.readFile(file, "utf8", function (err, data) { if (err) { return done(err); } else { templates[path.basename(file, ".ejs")] = _.template(data); done(); } }); }, function (err) { if (err) { return done(err); } done(null, templates); }); }); }
[ "function", "(", "done", ")", "{", "glob", "(", "path", ".", "join", "(", "__dirname", ",", "\"*.ejs\"", ")", ",", "function", "(", "err", ",", "files", ")", "{", "if", "(", "err", ")", "{", "return", "done", "(", "err", ")", ";", "}", "var", "templates", "=", "{", "}", ";", "async", ".", "forEach", "(", "files", ",", "function", "(", "file", ",", "done", ")", "{", "fs", ".", "readFile", "(", "file", ",", "\"utf8\"", ",", "function", "(", "err", ",", "data", ")", "{", "if", "(", "err", ")", "{", "return", "done", "(", "err", ")", ";", "}", "else", "{", "templates", "[", "path", ".", "basename", "(", "file", ",", "\".ejs\"", ")", "]", "=", "_", ".", "template", "(", "data", ")", ";", "done", "(", ")", ";", "}", "}", ")", ";", "}", ",", "function", "(", "err", ")", "{", "if", "(", "err", ")", "{", "return", "done", "(", "err", ")", ";", "}", "done", "(", "null", ",", "templates", ")", ";", "}", ")", ";", "}", ")", ";", "}" ]
gather the templates
[ "gather", "the", "templates" ]
4363d9b41fddd39db201472c44116aab1a010d99
https://github.com/dominicbarnes/node-couchdb-api/blob/4363d9b41fddd39db201472c44116aab1a010d99/docs/render.js#L11-L36
37,510
RoganMurley/hitagi.js
examples/example4/example4.js
function () { this.update = { gravity: function (entity, dt) { // Accelerate entity until it reaches terminal velocity. if (entity.c.velocity.yspeed < entity.c.gravity.terminal) { entity.c.velocity.yspeed += hitagi.utils.delta(entity.c.gravity.magnitude, dt); } } }; }
javascript
function () { this.update = { gravity: function (entity, dt) { // Accelerate entity until it reaches terminal velocity. if (entity.c.velocity.yspeed < entity.c.gravity.terminal) { entity.c.velocity.yspeed += hitagi.utils.delta(entity.c.gravity.magnitude, dt); } } }; }
[ "function", "(", ")", "{", "this", ".", "update", "=", "{", "gravity", ":", "function", "(", "entity", ",", "dt", ")", "{", "// Accelerate entity until it reaches terminal velocity.", "if", "(", "entity", ".", "c", ".", "velocity", ".", "yspeed", "<", "entity", ".", "c", ".", "gravity", ".", "terminal", ")", "{", "entity", ".", "c", ".", "velocity", ".", "yspeed", "+=", "hitagi", ".", "utils", ".", "delta", "(", "entity", ".", "c", ".", "gravity", ".", "magnitude", ",", "dt", ")", ";", "}", "}", "}", ";", "}" ]
Define systems.
[ "Define", "systems", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/examples/example4/example4.js#L17-L26
37,511
AntonyThorpe/knockout-apollo
demo/src/viewModel.js
function(data) { //initialise with a few Todos because we are very busy people self.todoList.insert(data.data.todoList); self.todoList2.insert(data.data.todoList); self.todoList3.insert(data.data.todoList); self.todoList4.insert(data.data.todoList); }
javascript
function(data) { //initialise with a few Todos because we are very busy people self.todoList.insert(data.data.todoList); self.todoList2.insert(data.data.todoList); self.todoList3.insert(data.data.todoList); self.todoList4.insert(data.data.todoList); }
[ "function", "(", "data", ")", "{", "//initialise with a few Todos because we are very busy people", "self", ".", "todoList", ".", "insert", "(", "data", ".", "data", ".", "todoList", ")", ";", "self", ".", "todoList2", ".", "insert", "(", "data", ".", "data", ".", "todoList", ")", ";", "self", ".", "todoList3", ".", "insert", "(", "data", ".", "data", ".", "todoList", ")", ";", "self", ".", "todoList4", ".", "insert", "(", "data", ".", "data", ".", "todoList", ")", ";", "}" ]
callback when successful
[ "callback", "when", "successful" ]
573a7caea7e41877710e69bac001771a6ea86d33
https://github.com/AntonyThorpe/knockout-apollo/blob/573a7caea7e41877710e69bac001771a6ea86d33/demo/src/viewModel.js#L102-L108
37,512
ToMMApps/express-waf
database/mongo-db.js
MongoDB
function MongoDB(host, port, database, collection, username, password){ _self = this; if(arguments.length < 3){ throw ("MongoDB constructor requires at least three arguments!"); } if(collection){ _collection = collection; } else{ _collection = DEFAULT_COLLECTION_NAME; } _username = username; _password = password; _host = host; //create new database connection _db = new Db(database, new Server(host, port), {safe:false}, {auto_reconnect: true}); }
javascript
function MongoDB(host, port, database, collection, username, password){ _self = this; if(arguments.length < 3){ throw ("MongoDB constructor requires at least three arguments!"); } if(collection){ _collection = collection; } else{ _collection = DEFAULT_COLLECTION_NAME; } _username = username; _password = password; _host = host; //create new database connection _db = new Db(database, new Server(host, port), {safe:false}, {auto_reconnect: true}); }
[ "function", "MongoDB", "(", "host", ",", "port", ",", "database", ",", "collection", ",", "username", ",", "password", ")", "{", "_self", "=", "this", ";", "if", "(", "arguments", ".", "length", "<", "3", ")", "{", "throw", "(", "\"MongoDB constructor requires at least three arguments!\"", ")", ";", "}", "if", "(", "collection", ")", "{", "_collection", "=", "collection", ";", "}", "else", "{", "_collection", "=", "DEFAULT_COLLECTION_NAME", ";", "}", "_username", "=", "username", ";", "_password", "=", "password", ";", "_host", "=", "host", ";", "//create new database connection", "_db", "=", "new", "Db", "(", "database", ",", "new", "Server", "(", "host", ",", "port", ")", ",", "{", "safe", ":", "false", "}", ",", "{", "auto_reconnect", ":", "true", "}", ")", ";", "}" ]
Wrapper class for MongoDB for use with the Blocker modules. Host and port specify on which computer MongoDB is running. @param host Host of the database which shall be used for the Blocklist. @param port Number of the port which shall be used for the Blocklist. @param database Name of the database which shall be used for the Blocklist. @param collection Name of the collection that shall be used for the Blocklist. @param username optional parameter for username to connect to database. @param password optional parameter for password to connect to database. @attention This class is permanently holding a connection to the database.
[ "Wrapper", "class", "for", "MongoDB", "for", "use", "with", "the", "Blocker", "modules", ".", "Host", "and", "port", "specify", "on", "which", "computer", "MongoDB", "is", "running", "." ]
5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a
https://github.com/ToMMApps/express-waf/blob/5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a/database/mongo-db.js#L28-L48
37,513
ToMMApps/express-waf
database/mongo-db.js
function(cb){ if(!_isOpen){ _self.open(function () { _self.removeAll(function() { getCollection(cb); }); }); } else { getCollection(cb); } function getCollection(cb) { _db.collection(_collection, cb); } }
javascript
function(cb){ if(!_isOpen){ _self.open(function () { _self.removeAll(function() { getCollection(cb); }); }); } else { getCollection(cb); } function getCollection(cb) { _db.collection(_collection, cb); } }
[ "function", "(", "cb", ")", "{", "if", "(", "!", "_isOpen", ")", "{", "_self", ".", "open", "(", "function", "(", ")", "{", "_self", ".", "removeAll", "(", "function", "(", ")", "{", "getCollection", "(", "cb", ")", ";", "}", ")", ";", "}", ")", ";", "}", "else", "{", "getCollection", "(", "cb", ")", ";", "}", "function", "getCollection", "(", "cb", ")", "{", "_db", ".", "collection", "(", "_collection", ",", "cb", ")", ";", "}", "}" ]
Gets the Blocklist collection from the MongoDB instance.
[ "Gets", "the", "Blocklist", "collection", "from", "the", "MongoDB", "instance", "." ]
5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a
https://github.com/ToMMApps/express-waf/blob/5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a/database/mongo-db.js#L79-L94
37,514
chriszarate/supergenpass-lib
src/lib/generate.js
hashRound
function hashRound(input, length, hashFunction, rounds, callback) { if (rounds > 0 || !validatePassword(input, length)) { process.nextTick(() => { hashRound(hashFunction(input), length, hashFunction, rounds - 1, callback); }); return; } process.nextTick(() => { callback(input.substring(0, length)); }); }
javascript
function hashRound(input, length, hashFunction, rounds, callback) { if (rounds > 0 || !validatePassword(input, length)) { process.nextTick(() => { hashRound(hashFunction(input), length, hashFunction, rounds - 1, callback); }); return; } process.nextTick(() => { callback(input.substring(0, length)); }); }
[ "function", "hashRound", "(", "input", ",", "length", ",", "hashFunction", ",", "rounds", ",", "callback", ")", "{", "if", "(", "rounds", ">", "0", "||", "!", "validatePassword", "(", "input", ",", "length", ")", ")", "{", "process", ".", "nextTick", "(", "(", ")", "=>", "{", "hashRound", "(", "hashFunction", "(", "input", ")", ",", "length", ",", "hashFunction", ",", "rounds", "-", "1", ",", "callback", ")", ";", "}", ")", ";", "return", ";", "}", "process", ".", "nextTick", "(", "(", ")", "=>", "{", "callback", "(", "input", ".", "substring", "(", "0", ",", "length", ")", ")", ";", "}", ")", ";", "}" ]
Hash the input for the requested number of rounds, then continue hashing until the password policy is satisfied. Finally, pass result to callback.
[ "Hash", "the", "input", "for", "the", "requested", "number", "of", "rounds", "then", "continue", "hashing", "until", "the", "password", "policy", "is", "satisfied", ".", "Finally", "pass", "result", "to", "callback", "." ]
eb9ee92050813d498229bfe0e6ccbcb87124cf90
https://github.com/chriszarate/supergenpass-lib/blob/eb9ee92050813d498229bfe0e6ccbcb87124cf90/src/lib/generate.js#L20-L30
37,515
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
selectColor
function selectColor(namespace) { var hash = 0, i; for (i in namespace) { hash = (hash << 5) - hash + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } return exports.colors[Math.abs(hash) % exports.colors.length]; }
javascript
function selectColor(namespace) { var hash = 0, i; for (i in namespace) { hash = (hash << 5) - hash + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } return exports.colors[Math.abs(hash) % exports.colors.length]; }
[ "function", "selectColor", "(", "namespace", ")", "{", "var", "hash", "=", "0", ",", "i", ";", "for", "(", "i", "in", "namespace", ")", "{", "hash", "=", "(", "hash", "<<", "5", ")", "-", "hash", "+", "namespace", ".", "charCodeAt", "(", "i", ")", ";", "hash", "|=", "0", ";", "// Convert to 32bit integer", "}", "return", "exports", ".", "colors", "[", "Math", ".", "abs", "(", "hash", ")", "%", "exports", ".", "colors", ".", "length", "]", ";", "}" ]
Select a color. @param {String} namespace @return {Number} @api private
[ "Select", "a", "color", "." ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L260-L270
37,516
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
isBuf
function isBuf(obj) { return ( (withNativeBuffer && commonjsGlobal.Buffer.isBuffer(obj)) || (withNativeArrayBuffer && (obj instanceof commonjsGlobal.ArrayBuffer || isView(obj))) ); }
javascript
function isBuf(obj) { return ( (withNativeBuffer && commonjsGlobal.Buffer.isBuffer(obj)) || (withNativeArrayBuffer && (obj instanceof commonjsGlobal.ArrayBuffer || isView(obj))) ); }
[ "function", "isBuf", "(", "obj", ")", "{", "return", "(", "(", "withNativeBuffer", "&&", "commonjsGlobal", ".", "Buffer", ".", "isBuffer", "(", "obj", ")", ")", "||", "(", "withNativeArrayBuffer", "&&", "(", "obj", "instanceof", "commonjsGlobal", ".", "ArrayBuffer", "||", "isView", "(", "obj", ")", ")", ")", ")", ";", "}" ]
Returns true if obj is a buffer or an arraybuffer. @api private
[ "Returns", "true", "if", "obj", "is", "a", "buffer", "or", "an", "arraybuffer", "." ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L1003-L1008
37,517
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
hasBinary
function hasBinary(obj) { if (!obj || typeof obj !== "object") { return false; } if (isarray(obj)) { for (var i = 0, l = obj.length; i < l; i++) { if (hasBinary(obj[i])) { return true; } } return false; } if ( (typeof Buffer === "function" && Buffer.isBuffer && Buffer.isBuffer(obj)) || (typeof ArrayBuffer === "function" && obj instanceof ArrayBuffer) || (withNativeBlob$1 && obj instanceof Blob) || (withNativeFile$1 && obj instanceof File) ) { return true; } // see: https://github.com/Automattic/has-binary/pull/4 if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) { return hasBinary(obj.toJSON(), true); } for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) { return true; } } return false; }
javascript
function hasBinary(obj) { if (!obj || typeof obj !== "object") { return false; } if (isarray(obj)) { for (var i = 0, l = obj.length; i < l; i++) { if (hasBinary(obj[i])) { return true; } } return false; } if ( (typeof Buffer === "function" && Buffer.isBuffer && Buffer.isBuffer(obj)) || (typeof ArrayBuffer === "function" && obj instanceof ArrayBuffer) || (withNativeBlob$1 && obj instanceof Blob) || (withNativeFile$1 && obj instanceof File) ) { return true; } // see: https://github.com/Automattic/has-binary/pull/4 if (obj.toJSON && typeof obj.toJSON === "function" && arguments.length === 1) { return hasBinary(obj.toJSON(), true); } for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) { return true; } } return false; }
[ "function", "hasBinary", "(", "obj", ")", "{", "if", "(", "!", "obj", "||", "typeof", "obj", "!==", "\"object\"", ")", "{", "return", "false", ";", "}", "if", "(", "isarray", "(", "obj", ")", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "obj", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "hasBinary", "(", "obj", "[", "i", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "if", "(", "(", "typeof", "Buffer", "===", "\"function\"", "&&", "Buffer", ".", "isBuffer", "&&", "Buffer", ".", "isBuffer", "(", "obj", ")", ")", "||", "(", "typeof", "ArrayBuffer", "===", "\"function\"", "&&", "obj", "instanceof", "ArrayBuffer", ")", "||", "(", "withNativeBlob$1", "&&", "obj", "instanceof", "Blob", ")", "||", "(", "withNativeFile$1", "&&", "obj", "instanceof", "File", ")", ")", "{", "return", "true", ";", "}", "// see: https://github.com/Automattic/has-binary/pull/4", "if", "(", "obj", ".", "toJSON", "&&", "typeof", "obj", ".", "toJSON", "===", "\"function\"", "&&", "arguments", ".", "length", "===", "1", ")", "{", "return", "hasBinary", "(", "obj", ".", "toJSON", "(", ")", ",", "true", ")", ";", "}", "for", "(", "var", "key", "in", "obj", ")", "{", "if", "(", "Object", ".", "prototype", ".", "hasOwnProperty", ".", "call", "(", "obj", ",", "key", ")", "&&", "hasBinary", "(", "obj", "[", "key", "]", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks for binary data. Supports Buffer, ArrayBuffer, Blob and File. @param {Object} anything @api public
[ "Checks", "for", "binary", "data", "." ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L1680-L1715
37,518
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
function(obj) { var str = ""; for (var i in obj) { if (obj.hasOwnProperty(i)) { if (str.length) str += "&"; str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]); } } return str; }
javascript
function(obj) { var str = ""; for (var i in obj) { if (obj.hasOwnProperty(i)) { if (str.length) str += "&"; str += encodeURIComponent(i) + "=" + encodeURIComponent(obj[i]); } } return str; }
[ "function", "(", "obj", ")", "{", "var", "str", "=", "\"\"", ";", "for", "(", "var", "i", "in", "obj", ")", "{", "if", "(", "obj", ".", "hasOwnProperty", "(", "i", ")", ")", "{", "if", "(", "str", ".", "length", ")", "str", "+=", "\"&\"", ";", "str", "+=", "encodeURIComponent", "(", "i", ")", "+", "\"=\"", "+", "encodeURIComponent", "(", "obj", "[", "i", "]", ")", ";", "}", "}", "return", "str", ";", "}" ]
Compiles a querystring Returns string representation of the object @param {Object} @api private
[ "Compiles", "a", "querystring", "Returns", "string", "representation", "of", "the", "object" ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L2982-L2993
37,519
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
Polling
function Polling(opts) { var forceBase64 = opts && opts.forceBase64; if (!hasXHR2 || forceBase64) { this.supportsBinary = false; } transport.call(this, opts); }
javascript
function Polling(opts) { var forceBase64 = opts && opts.forceBase64; if (!hasXHR2 || forceBase64) { this.supportsBinary = false; } transport.call(this, opts); }
[ "function", "Polling", "(", "opts", ")", "{", "var", "forceBase64", "=", "opts", "&&", "opts", ".", "forceBase64", ";", "if", "(", "!", "hasXHR2", "||", "forceBase64", ")", "{", "this", ".", "supportsBinary", "=", "false", ";", "}", "transport", ".", "call", "(", "this", ",", "opts", ")", ";", "}" ]
Polling interface. @param {Object} opts @api private
[ "Polling", "interface", "." ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L3120-L3126
37,520
compose-us/todastic
packages/server-web/src/client/socket.io-bundle.js
onerror
function onerror(err) { var error = new Error("probe error: " + err); error.transport = transport$$1.name; freezeTransport(); debug$5('probe transport "%s" failed because of error: %s', name, err); self.emit("upgradeError", error); }
javascript
function onerror(err) { var error = new Error("probe error: " + err); error.transport = transport$$1.name; freezeTransport(); debug$5('probe transport "%s" failed because of error: %s', name, err); self.emit("upgradeError", error); }
[ "function", "onerror", "(", "err", ")", "{", "var", "error", "=", "new", "Error", "(", "\"probe error: \"", "+", "err", ")", ";", "error", ".", "transport", "=", "transport$$1", ".", "name", ";", "freezeTransport", "(", ")", ";", "debug$5", "(", "'probe transport \"%s\" failed because of error: %s'", ",", "name", ",", "err", ")", ";", "self", ".", "emit", "(", "\"upgradeError\"", ",", "error", ")", ";", "}" ]
Handle any error that happens while probing
[ "Handle", "any", "error", "that", "happens", "while", "probing" ]
4807d8e564905a2b49fe90d8046be9f1a19cf344
https://github.com/compose-us/todastic/blob/4807d8e564905a2b49fe90d8046be9f1a19cf344/packages/server-web/src/client/socket.io-bundle.js#L4674-L4683
37,521
adobe/react-twist-webpack-plugin
src/convertRuleToCondition.js
convertRuleToCondition
function convertRuleToCondition(rule) { if (!rule || typeof rule !== 'object' || !Object.keys(rule).length) { return rule; } if (Array.isArray(rule)) { return rule.map(convertRuleToCondition); } const condition = {}; // We allow certain properties... ALLOWED_PROPERTIES.forEach((prop) => { if (rule[prop]) { condition[prop] = convertRuleToCondition(rule[prop]); } }); // We prohibit certain properties... PROHIBITIED_PROPERTIES.forEach((prop) => { if (rule[prop]) { throw new Error(`Webpack rules added in a Twist library cannot contain the property "${prop}". ` + `Try to reformulate your rule with ${ALLOWED_PROPERTIES.join('/')}.`); } }); // And the rest we ignore, because they're needed for a Rule but not a Condition. return condition; }
javascript
function convertRuleToCondition(rule) { if (!rule || typeof rule !== 'object' || !Object.keys(rule).length) { return rule; } if (Array.isArray(rule)) { return rule.map(convertRuleToCondition); } const condition = {}; // We allow certain properties... ALLOWED_PROPERTIES.forEach((prop) => { if (rule[prop]) { condition[prop] = convertRuleToCondition(rule[prop]); } }); // We prohibit certain properties... PROHIBITIED_PROPERTIES.forEach((prop) => { if (rule[prop]) { throw new Error(`Webpack rules added in a Twist library cannot contain the property "${prop}". ` + `Try to reformulate your rule with ${ALLOWED_PROPERTIES.join('/')}.`); } }); // And the rest we ignore, because they're needed for a Rule but not a Condition. return condition; }
[ "function", "convertRuleToCondition", "(", "rule", ")", "{", "if", "(", "!", "rule", "||", "typeof", "rule", "!==", "'object'", "||", "!", "Object", ".", "keys", "(", "rule", ")", ".", "length", ")", "{", "return", "rule", ";", "}", "if", "(", "Array", ".", "isArray", "(", "rule", ")", ")", "{", "return", "rule", ".", "map", "(", "convertRuleToCondition", ")", ";", "}", "const", "condition", "=", "{", "}", ";", "// We allow certain properties...", "ALLOWED_PROPERTIES", ".", "forEach", "(", "(", "prop", ")", "=>", "{", "if", "(", "rule", "[", "prop", "]", ")", "{", "condition", "[", "prop", "]", "=", "convertRuleToCondition", "(", "rule", "[", "prop", "]", ")", ";", "}", "}", ")", ";", "// We prohibit certain properties...", "PROHIBITIED_PROPERTIES", ".", "forEach", "(", "(", "prop", ")", "=>", "{", "if", "(", "rule", "[", "prop", "]", ")", "{", "throw", "new", "Error", "(", "`", "${", "prop", "}", "`", "+", "`", "${", "ALLOWED_PROPERTIES", ".", "join", "(", "'/'", ")", "}", "`", ")", ";", "}", "}", ")", ";", "// And the rest we ignore, because they're needed for a Rule but not a Condition.", "return", "condition", ";", "}" ]
Create a Webpack Condition from a Webpack Rule by stripping out any nested Rule properties, keeping only the conditions in which the rule would be applied. In other words, the return value of this function could be passed to `exclude` on another rule, to exclude only the files matched by the input rule. @param {Rule} rule @return {Condition}
[ "Create", "a", "Webpack", "Condition", "from", "a", "Webpack", "Rule", "by", "stripping", "out", "any", "nested", "Rule", "properties", "keeping", "only", "the", "conditions", "in", "which", "the", "rule", "would", "be", "applied", ".", "In", "other", "words", "the", "return", "value", "of", "this", "function", "could", "be", "passed", "to", "exclude", "on", "another", "rule", "to", "exclude", "only", "the", "files", "matched", "by", "the", "input", "rule", "." ]
499949d69931904eb5a2b7ef12cf9c1848ce6241
https://github.com/adobe/react-twist-webpack-plugin/blob/499949d69931904eb5a2b7ef12cf9c1848ce6241/src/convertRuleToCondition.js#L33-L56
37,522
carsdotcom/windshieldjs
lib/processRoutes.js
processRoutes
function processRoutes(handler, uriContext, routes) { return routes.map(setupRoute); /** * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing * an incoming request * @param {pageFilter} pageFilter - Function for performing post-processing on page object before * templating begins * @param {string} method - HTTP method for the route * @param {string} path - Path for the route * @param {module:processRoutes.Context} context * - Data that should be made available to the adapters and route handler * * @returns {object} Hapi route options object */ function setupRoute({adapters, pageFilter, method, path, context}) { const allAdaptersAndPreHandlers = flattenDeep(adapters); const preHandlers = allAdaptersAndPreHandlers.filter(x => isPreHandler(x)); const pageAdapters = allAdaptersAndPreHandlers.filter(x => !isPreHandler(x)); const app = { context, adapters: pageAdapters }; if (pageFilter) { app.pageFilter = pageFilter; } const pre = preHandlers.map(mapToWrappedHandler); return { method, path: uriContext + path, handler, config: { state: { failAction: 'log' }, app, pre } }; } }
javascript
function processRoutes(handler, uriContext, routes) { return routes.map(setupRoute); /** * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing * an incoming request * @param {pageFilter} pageFilter - Function for performing post-processing on page object before * templating begins * @param {string} method - HTTP method for the route * @param {string} path - Path for the route * @param {module:processRoutes.Context} context * - Data that should be made available to the adapters and route handler * * @returns {object} Hapi route options object */ function setupRoute({adapters, pageFilter, method, path, context}) { const allAdaptersAndPreHandlers = flattenDeep(adapters); const preHandlers = allAdaptersAndPreHandlers.filter(x => isPreHandler(x)); const pageAdapters = allAdaptersAndPreHandlers.filter(x => !isPreHandler(x)); const app = { context, adapters: pageAdapters }; if (pageFilter) { app.pageFilter = pageFilter; } const pre = preHandlers.map(mapToWrappedHandler); return { method, path: uriContext + path, handler, config: { state: { failAction: 'log' }, app, pre } }; } }
[ "function", "processRoutes", "(", "handler", ",", "uriContext", ",", "routes", ")", "{", "return", "routes", ".", "map", "(", "setupRoute", ")", ";", "/**\n * @param {(PreReq|pageAdapter)[]} adapters - Array of adapters and Hapi route prerequisites for processing\n * an incoming request\n * @param {pageFilter} pageFilter - Function for performing post-processing on page object before\n * templating begins\n * @param {string} method - HTTP method for the route\n * @param {string} path - Path for the route\n * @param {module:processRoutes.Context} context\n * - Data that should be made available to the adapters and route handler\n *\n * @returns {object} Hapi route options object\n */", "function", "setupRoute", "(", "{", "adapters", ",", "pageFilter", ",", "method", ",", "path", ",", "context", "}", ")", "{", "const", "allAdaptersAndPreHandlers", "=", "flattenDeep", "(", "adapters", ")", ";", "const", "preHandlers", "=", "allAdaptersAndPreHandlers", ".", "filter", "(", "x", "=>", "isPreHandler", "(", "x", ")", ")", ";", "const", "pageAdapters", "=", "allAdaptersAndPreHandlers", ".", "filter", "(", "x", "=>", "!", "isPreHandler", "(", "x", ")", ")", ";", "const", "app", "=", "{", "context", ",", "adapters", ":", "pageAdapters", "}", ";", "if", "(", "pageFilter", ")", "{", "app", ".", "pageFilter", "=", "pageFilter", ";", "}", "const", "pre", "=", "preHandlers", ".", "map", "(", "mapToWrappedHandler", ")", ";", "return", "{", "method", ",", "path", ":", "uriContext", "+", "path", ",", "handler", ",", "config", ":", "{", "state", ":", "{", "failAction", ":", "'log'", "}", ",", "app", ",", "pre", "}", "}", ";", "}", "}" ]
Converts an array of Windshield routes into a an array of Hapi routes. Each route will use the same handler method, which accesses a set of Windshield adapters from the route to build a page object, and define a layout template to compile the page object into a web page. @param {handler} handler - Hapi route handler method @param {module:processRoutes.Route[]} routes - Array of Windshield route objects, which are processed into Hapi routes @param {string} uriContext - the URI context to be prepended to the paths of each route. @returns {object[]} - An array of Hapi route options objects
[ "Converts", "an", "array", "of", "Windshield", "routes", "into", "a", "an", "array", "of", "Hapi", "routes", ".", "Each", "route", "will", "use", "the", "same", "handler", "method", "which", "accesses", "a", "set", "of", "Windshield", "adapters", "from", "the", "route", "to", "build", "a", "page", "object", "and", "define", "a", "layout", "template", "to", "compile", "the", "page", "object", "into", "a", "web", "page", "." ]
fddd841c5d9e09251437c9a30cc39700e5e4a1f6
https://github.com/carsdotcom/windshieldjs/blob/fddd841c5d9e09251437c9a30cc39700e5e4a1f6/lib/processRoutes.js#L37-L82
37,523
atomantic/undermore
dist/undermore.js
function (object) { var sortedObj = {}, keys = _.keys(object); keys = _.sortBy(keys, function(key){ return key; }); _.each(keys, function(key) { if(_.isArray(object[key])) { sortedObj[key] = _.map(object[key], function(val) { return _.isObject(val) ? _.alphabetize(val) : val; }); } else if(_.isObject(object[key])){ sortedObj[key] = _.alphabetize(object[key]); } else { sortedObj[key] = object[key]; } }); return sortedObj; }
javascript
function (object) { var sortedObj = {}, keys = _.keys(object); keys = _.sortBy(keys, function(key){ return key; }); _.each(keys, function(key) { if(_.isArray(object[key])) { sortedObj[key] = _.map(object[key], function(val) { return _.isObject(val) ? _.alphabetize(val) : val; }); } else if(_.isObject(object[key])){ sortedObj[key] = _.alphabetize(object[key]); } else { sortedObj[key] = object[key]; } }); return sortedObj; }
[ "function", "(", "object", ")", "{", "var", "sortedObj", "=", "{", "}", ",", "keys", "=", "_", ".", "keys", "(", "object", ")", ";", "keys", "=", "_", ".", "sortBy", "(", "keys", ",", "function", "(", "key", ")", "{", "return", "key", ";", "}", ")", ";", "_", ".", "each", "(", "keys", ",", "function", "(", "key", ")", "{", "if", "(", "_", ".", "isArray", "(", "object", "[", "key", "]", ")", ")", "{", "sortedObj", "[", "key", "]", "=", "_", ".", "map", "(", "object", "[", "key", "]", ",", "function", "(", "val", ")", "{", "return", "_", ".", "isObject", "(", "val", ")", "?", "_", ".", "alphabetize", "(", "val", ")", ":", "val", ";", "}", ")", ";", "}", "else", "if", "(", "_", ".", "isObject", "(", "object", "[", "key", "]", ")", ")", "{", "sortedObj", "[", "key", "]", "=", "_", ".", "alphabetize", "(", "object", "[", "key", "]", ")", ";", "}", "else", "{", "sortedObj", "[", "key", "]", "=", "object", "[", "key", "]", ";", "}", "}", ")", ";", "return", "sortedObj", ";", "}" ]
sort the keys in an object alphabetically, recursively @function module:undermore.alphabetize @param {object} obj The object to traverse @return {mixed} the object with alphabetized keys @example var obj = { b: 1, a: 2 }; JSON.stringify(_.alphabetize(obj)) === '{"a":2,"b":1}'
[ "sort", "the", "keys", "in", "an", "object", "alphabetically", "recursively" ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/dist/undermore.js#L71-L92
37,524
atomantic/undermore
dist/undermore.js
function(str) { // allow browser implementation if it exists // https://developer.mozilla.org/en-US/docs/Web/API/window.btoa if (typeof atob!=='undefined') { // utf8 decode after the fact to make sure we convert > 0xFF to ascii return _.utf8_decode(atob(str)); } // allow node.js Buffer implementation if it exists if (Buffer) { return new Buffer(str, 'base64').toString('binary'); } // now roll our own // decoder // [https://gist.github.com/1020396] by [https://github.com/atk] str = str.replace(/=+$/, ''); for ( // initialize result and counters var bc = 0, bs, buffer, idx = 0, output = ''; // get next character buffer = str.charAt(idx++); // character found in table? initialize bit storage and add its ascii value; ~ buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, // and if not first of each 4 characters, // convert the first 8 bits to one ascii character bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 ) { // try to find character in table (0-63, not found => -1) buffer = chars.indexOf(buffer); } return output; }
javascript
function(str) { // allow browser implementation if it exists // https://developer.mozilla.org/en-US/docs/Web/API/window.btoa if (typeof atob!=='undefined') { // utf8 decode after the fact to make sure we convert > 0xFF to ascii return _.utf8_decode(atob(str)); } // allow node.js Buffer implementation if it exists if (Buffer) { return new Buffer(str, 'base64').toString('binary'); } // now roll our own // decoder // [https://gist.github.com/1020396] by [https://github.com/atk] str = str.replace(/=+$/, ''); for ( // initialize result and counters var bc = 0, bs, buffer, idx = 0, output = ''; // get next character buffer = str.charAt(idx++); // character found in table? initialize bit storage and add its ascii value; ~ buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer, // and if not first of each 4 characters, // convert the first 8 bits to one ascii character bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0 ) { // try to find character in table (0-63, not found => -1) buffer = chars.indexOf(buffer); } return output; }
[ "function", "(", "str", ")", "{", "// allow browser implementation if it exists", "// https://developer.mozilla.org/en-US/docs/Web/API/window.btoa", "if", "(", "typeof", "atob", "!==", "'undefined'", ")", "{", "// utf8 decode after the fact to make sure we convert > 0xFF to ascii", "return", "_", ".", "utf8_decode", "(", "atob", "(", "str", ")", ")", ";", "}", "// allow node.js Buffer implementation if it exists", "if", "(", "Buffer", ")", "{", "return", "new", "Buffer", "(", "str", ",", "'base64'", ")", ".", "toString", "(", "'binary'", ")", ";", "}", "// now roll our own", "// decoder", "// [https://gist.github.com/1020396] by [https://github.com/atk]", "str", "=", "str", ".", "replace", "(", "/", "=+$", "/", ",", "''", ")", ";", "for", "(", "// initialize result and counters", "var", "bc", "=", "0", ",", "bs", ",", "buffer", ",", "idx", "=", "0", ",", "output", "=", "''", ";", "// get next character", "buffer", "=", "str", ".", "charAt", "(", "idx", "++", ")", ";", "// character found in table? initialize bit storage and add its ascii value;", "~", "buffer", "&&", "(", "bs", "=", "bc", "%", "4", "?", "bs", "*", "64", "+", "buffer", ":", "buffer", ",", "// and if not first of each 4 characters,", "// convert the first 8 bits to one ascii character", "bc", "++", "%", "4", ")", "?", "output", "+=", "String", ".", "fromCharCode", "(", "255", "&", "bs", ">>", "(", "-", "2", "*", "bc", "&", "6", ")", ")", ":", "0", ")", "{", "// try to find character in table (0-63, not found => -1)", "buffer", "=", "chars", ".", "indexOf", "(", "buffer", ")", ";", "}", "return", "output", ";", "}" ]
base64_decode decode a string. This is not a strict polyfill for window.atob because it handles unicode characters @function module:undermore.base64_decode @link https://github.com/davidchambers/Base64.js @param {string} str The string to decode @return {string} @example _.base64_decode('4pyI') => '✈'
[ "base64_decode", "decode", "a", "string", ".", "This", "is", "not", "a", "strict", "polyfill", "for", "window", ".", "atob", "because", "it", "handles", "unicode", "characters" ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/dist/undermore.js#L103-L134
37,525
atomantic/undermore
dist/undermore.js
function(originalFn, moreFn, scope) { return scope ? function() { originalFn.apply(scope, arguments); moreFn.apply(scope, arguments); } : function() { originalFn(); moreFn(); }; }
javascript
function(originalFn, moreFn, scope) { return scope ? function() { originalFn.apply(scope, arguments); moreFn.apply(scope, arguments); } : function() { originalFn(); moreFn(); }; }
[ "function", "(", "originalFn", ",", "moreFn", ",", "scope", ")", "{", "return", "scope", "?", "function", "(", ")", "{", "originalFn", ".", "apply", "(", "scope", ",", "arguments", ")", ";", "moreFn", ".", "apply", "(", "scope", ",", "arguments", ")", ";", "}", ":", "function", "(", ")", "{", "originalFn", "(", ")", ";", "moreFn", "(", ")", ";", "}", ";", "}" ]
get a new function, which runs two functions serially within a given context @function module:undermore.fnMore @param {function} originalFn The original function to run @param {function} moreFn The extra function to run in the same context after the first @param {object} scope The context in which to run the fn @return {function} the new function which will serially call the given functions in the given scope @example var fn = _.fnMore(oldFn,newFn,someObj); fn(); // runs oldFn, then newFn in the context of someObj
[ "get", "a", "new", "function", "which", "runs", "two", "functions", "serially", "within", "a", "given", "context" ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/dist/undermore.js#L215-L224
37,526
yangyxu/zeanium
dist/zn.reactnative.js
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; if(!_exist){ _descriptor = Object.defineProperty(target, 'on' + name.toLowerCase(), { get: function () { var _listeners = this.__handlers__[name]; if (_listeners) { return _listeners[0].handler; } else { return null; } }, set: function (value) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = { owner: this, handler: value, context: null }; } }); } _ctor[_key] = { name: name, type: 'event', meta: meta, descriptor: _descriptor }; return _exist; }
javascript
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; if(!_exist){ _descriptor = Object.defineProperty(target, 'on' + name.toLowerCase(), { get: function () { var _listeners = this.__handlers__[name]; if (_listeners) { return _listeners[0].handler; } else { return null; } }, set: function (value) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = { owner: this, handler: value, context: null }; } }); } _ctor[_key] = { name: name, type: 'event', meta: meta, descriptor: _descriptor }; return _exist; }
[ "function", "(", "target", ",", "name", ",", "meta", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", ")", ",", "_key", "=", "__define", ".", "fixTargetKey", "(", "name", ")", ",", "_exist", "=", "_key", "in", "_ctor", ",", "_descriptor", "=", "{", "}", ";", "if", "(", "!", "_exist", ")", "{", "_descriptor", "=", "Object", ".", "defineProperty", "(", "target", ",", "'on'", "+", "name", ".", "toLowerCase", "(", ")", ",", "{", "get", ":", "function", "(", ")", "{", "var", "_listeners", "=", "this", ".", "__handlers__", "[", "name", "]", ";", "if", "(", "_listeners", ")", "{", "return", "_listeners", "[", "0", "]", ".", "handler", ";", "}", "else", "{", "return", "null", ";", "}", "}", ",", "set", ":", "function", "(", "value", ")", "{", "var", "_handlers", "=", "this", ".", "__handlers__", ";", "var", "_listeners", "=", "_handlers", "[", "name", "]", "=", "_handlers", "[", "name", "]", "||", "[", "]", ";", "_listeners", "[", "0", "]", "=", "{", "owner", ":", "this", ",", "handler", ":", "value", ",", "context", ":", "null", "}", ";", "}", "}", ")", ";", "}", "_ctor", "[", "_key", "]", "=", "{", "name", ":", "name", ",", "type", ":", "'event'", ",", "meta", ":", "meta", ",", "descriptor", ":", "_descriptor", "}", ";", "return", "_exist", ";", "}" ]
Define an event for target @param target @param name @param meta @returns {boolean}
[ "Define", "an", "event", "for", "target" ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L762-L799
37,527
yangyxu/zeanium
dist/zn.reactnative.js
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; var _getter, _setter; if ('value' in meta) { var _value = meta.value, _field = '_' + name, _get = meta.get, _set = meta.set; _getter = _get || function () { if (_field in this) { return this[_field]; } else { return zn.is(_value, 'function') ? _value.call(this) : _value; } }; _setter = meta.readonly ? function (value, options) { if (options && options.force) { this[_field] = value; } else { return false; } } : (_set ||function (value) { this[_field] = value; }); } else { _getter = meta.get || function () { return undefined; }; _setter = meta.set || function () { return false; }; } if (_exist) { _getter.__super__ = _ctor[_key].getter; _setter.__super__ = _ctor[_key].setter; } /* if(!_exist){ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); }*/ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); _ctor[_key] = { name: name, type: 'property', meta: meta, getter: _getter, setter: _setter, descriptor: _descriptor }; return _exist; }
javascript
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor, _descriptor = {}; var _getter, _setter; if ('value' in meta) { var _value = meta.value, _field = '_' + name, _get = meta.get, _set = meta.set; _getter = _get || function () { if (_field in this) { return this[_field]; } else { return zn.is(_value, 'function') ? _value.call(this) : _value; } }; _setter = meta.readonly ? function (value, options) { if (options && options.force) { this[_field] = value; } else { return false; } } : (_set ||function (value) { this[_field] = value; }); } else { _getter = meta.get || function () { return undefined; }; _setter = meta.set || function () { return false; }; } if (_exist) { _getter.__super__ = _ctor[_key].getter; _setter.__super__ = _ctor[_key].setter; } /* if(!_exist){ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); }*/ _descriptor = Object.defineProperty(target, name, { get: _getter, set: _setter, configurable : true }); _ctor[_key] = { name: name, type: 'property', meta: meta, getter: _getter, setter: _setter, descriptor: _descriptor }; return _exist; }
[ "function", "(", "target", ",", "name", ",", "meta", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", ")", ",", "_key", "=", "__define", ".", "fixTargetKey", "(", "name", ")", ",", "_exist", "=", "_key", "in", "_ctor", ",", "_descriptor", "=", "{", "}", ";", "var", "_getter", ",", "_setter", ";", "if", "(", "'value'", "in", "meta", ")", "{", "var", "_value", "=", "meta", ".", "value", ",", "_field", "=", "'_'", "+", "name", ",", "_get", "=", "meta", ".", "get", ",", "_set", "=", "meta", ".", "set", ";", "_getter", "=", "_get", "||", "function", "(", ")", "{", "if", "(", "_field", "in", "this", ")", "{", "return", "this", "[", "_field", "]", ";", "}", "else", "{", "return", "zn", ".", "is", "(", "_value", ",", "'function'", ")", "?", "_value", ".", "call", "(", "this", ")", ":", "_value", ";", "}", "}", ";", "_setter", "=", "meta", ".", "readonly", "?", "function", "(", "value", ",", "options", ")", "{", "if", "(", "options", "&&", "options", ".", "force", ")", "{", "this", "[", "_field", "]", "=", "value", ";", "}", "else", "{", "return", "false", ";", "}", "}", ":", "(", "_set", "||", "function", "(", "value", ")", "{", "this", "[", "_field", "]", "=", "value", ";", "}", ")", ";", "}", "else", "{", "_getter", "=", "meta", ".", "get", "||", "function", "(", ")", "{", "return", "undefined", ";", "}", ";", "_setter", "=", "meta", ".", "set", "||", "function", "(", ")", "{", "return", "false", ";", "}", ";", "}", "if", "(", "_exist", ")", "{", "_getter", ".", "__super__", "=", "_ctor", "[", "_key", "]", ".", "getter", ";", "_setter", ".", "__super__", "=", "_ctor", "[", "_key", "]", ".", "setter", ";", "}", "/*\n if(!_exist){\n _descriptor = Object.defineProperty(target, name, {\n get: _getter,\n set: _setter,\n configurable : true\n });\n }*/", "_descriptor", "=", "Object", ".", "defineProperty", "(", "target", ",", "name", ",", "{", "get", ":", "_getter", ",", "set", ":", "_setter", ",", "configurable", ":", "true", "}", ")", ";", "_ctor", "[", "_key", "]", "=", "{", "name", ":", "name", ",", "type", ":", "'property'", ",", "meta", ":", "meta", ",", "getter", ":", "_getter", ",", "setter", ":", "_setter", ",", "descriptor", ":", "_descriptor", "}", ";", "return", "_exist", ";", "}" ]
Define a property for target @param target @param name @param meta @returns {boolean}
[ "Define", "a", "property", "for", "target" ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L807-L880
37,528
yangyxu/zeanium
dist/zn.reactnative.js
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor; _ctor[_key] = { name: name, type: 'method', meta: meta }; if (name in target) { if(!meta.value){ meta.value = function (){ }; } meta.value.__super__ = target[name]; } target[name] = meta.value; return _exist; }
javascript
function (target, name, meta){ var _ctor = __define.fixTargetCtor(target), _key = __define.fixTargetKey(name), _exist = _key in _ctor; _ctor[_key] = { name: name, type: 'method', meta: meta }; if (name in target) { if(!meta.value){ meta.value = function (){ }; } meta.value.__super__ = target[name]; } target[name] = meta.value; return _exist; }
[ "function", "(", "target", ",", "name", ",", "meta", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", ")", ",", "_key", "=", "__define", ".", "fixTargetKey", "(", "name", ")", ",", "_exist", "=", "_key", "in", "_ctor", ";", "_ctor", "[", "_key", "]", "=", "{", "name", ":", "name", ",", "type", ":", "'method'", ",", "meta", ":", "meta", "}", ";", "if", "(", "name", "in", "target", ")", "{", "if", "(", "!", "meta", ".", "value", ")", "{", "meta", ".", "value", "=", "function", "(", ")", "{", "}", ";", "}", "meta", ".", "value", ".", "__super__", "=", "target", "[", "name", "]", ";", "}", "target", "[", "name", "]", "=", "meta", ".", "value", ";", "return", "_exist", ";", "}" ]
Define a method for target @param target @param name @param meta @returns {boolean}
[ "Define", "a", "method", "for", "target" ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L888-L912
37,529
yangyxu/zeanium
dist/zn.reactnative.js
function (name, target) { var _ctor = __define.fixTargetCtor(target||this), _member = _ctor[__define.fixTargetKey(name)]; if(!_member&&_ctor!==ZNObject){ return this.member(name, _ctor._super_); } return _member; }
javascript
function (name, target) { var _ctor = __define.fixTargetCtor(target||this), _member = _ctor[__define.fixTargetKey(name)]; if(!_member&&_ctor!==ZNObject){ return this.member(name, _ctor._super_); } return _member; }
[ "function", "(", "name", ",", "target", ")", "{", "var", "_ctor", "=", "__define", ".", "fixTargetCtor", "(", "target", "||", "this", ")", ",", "_member", "=", "_ctor", "[", "__define", ".", "fixTargetKey", "(", "name", ")", "]", ";", "if", "(", "!", "_member", "&&", "_ctor", "!==", "ZNObject", ")", "{", "return", "this", ".", "member", "(", "name", ",", "_ctor", ".", "_super_", ")", ";", "}", "return", "_member", ";", "}" ]
Get specified member. @param name @returns {*}
[ "Get", "specified", "member", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L923-L932
37,530
yangyxu/zeanium
dist/zn.reactnative.js
function (name, options) { var _member = this.member(name); if(_member && _member.getter){ return _member.getter.call(this, options); } return undefined; }
javascript
function (name, options) { var _member = this.member(name); if(_member && _member.getter){ return _member.getter.call(this, options); } return undefined; }
[ "function", "(", "name", ",", "options", ")", "{", "var", "_member", "=", "this", ".", "member", "(", "name", ")", ";", "if", "(", "_member", "&&", "_member", ".", "getter", ")", "{", "return", "_member", ".", "getter", ".", "call", "(", "this", ",", "options", ")", ";", "}", "return", "undefined", ";", "}" ]
Get specified property value. @method get @param name {String} @param [options] {Any} @returns {*}
[ "Get", "specified", "property", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L970-L977
37,531
yangyxu/zeanium
dist/zn.reactnative.js
function (name, value, options) { var _member = this.member(name); if (_member && _member.setter) { _member.setter.call(this, value, options); } return this; }
javascript
function (name, value, options) { var _member = this.member(name); if (_member && _member.setter) { _member.setter.call(this, value, options); } return this; }
[ "function", "(", "name", ",", "value", ",", "options", ")", "{", "var", "_member", "=", "this", ".", "member", "(", "name", ")", ";", "if", "(", "_member", "&&", "_member", ".", "setter", ")", "{", "_member", ".", "setter", ".", "call", "(", "this", ",", "value", ",", "options", ")", ";", "}", "return", "this", ";", "}" ]
Set specified property value. @method set @param name {String} @param value {*} @param [options] {Any}
[ "Set", "specified", "property", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L985-L992
37,532
yangyxu/zeanium
dist/zn.reactnative.js
function (options) { var _values = {}, _properties = __define.fixTargetCtor(this)._properties_; zn.each(_properties, function (name) { _values[name] = this.get(name, options); }, this); return _values; }
javascript
function (options) { var _values = {}, _properties = __define.fixTargetCtor(this)._properties_; zn.each(_properties, function (name) { _values[name] = this.get(name, options); }, this); return _values; }
[ "function", "(", "options", ")", "{", "var", "_values", "=", "{", "}", ",", "_properties", "=", "__define", ".", "fixTargetCtor", "(", "this", ")", ".", "_properties_", ";", "zn", ".", "each", "(", "_properties", ",", "function", "(", "name", ")", "{", "_values", "[", "name", "]", "=", "this", ".", "get", "(", "name", ",", "options", ")", ";", "}", ",", "this", ")", ";", "return", "_values", ";", "}" ]
Get all properties. @method gets @returns {Object} @param [options] {Any}
[ "Get", "all", "properties", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L999-L1007
37,533
yangyxu/zeanium
dist/zn.reactnative.js
function (values, options, callback) { if (values) { var _value = null; for (var _name in values) { if (values.hasOwnProperty(_name)) { _value = values[_name]; if((callback && callback(_value, _name, options))!==false){ this.set(_name, _value, options); } } } } return this; }
javascript
function (values, options, callback) { if (values) { var _value = null; for (var _name in values) { if (values.hasOwnProperty(_name)) { _value = values[_name]; if((callback && callback(_value, _name, options))!==false){ this.set(_name, _value, options); } } } } return this; }
[ "function", "(", "values", ",", "options", ",", "callback", ")", "{", "if", "(", "values", ")", "{", "var", "_value", "=", "null", ";", "for", "(", "var", "_name", "in", "values", ")", "{", "if", "(", "values", ".", "hasOwnProperty", "(", "_name", ")", ")", "{", "_value", "=", "values", "[", "_name", "]", ";", "if", "(", "(", "callback", "&&", "callback", "(", "_value", ",", "_name", ",", "options", ")", ")", "!==", "false", ")", "{", "this", ".", "set", "(", "_name", ",", "_value", ",", "options", ")", ";", "}", "}", "}", "}", "return", "this", ";", "}" ]
Set a bunch of properties. @method sets @param dict {Object} @param [options] {Any}
[ "Set", "a", "bunch", "of", "properties", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1014-L1028
37,534
yangyxu/zeanium
dist/zn.reactnative.js
function (name, meta, target) { if (!__define.defineEvent(target || this.prototype, name, meta)) { this._events_.push(name); } return this; }
javascript
function (name, meta, target) { if (!__define.defineEvent(target || this.prototype, name, meta)) { this._events_.push(name); } return this; }
[ "function", "(", "name", ",", "meta", ",", "target", ")", "{", "if", "(", "!", "__define", ".", "defineEvent", "(", "target", "||", "this", ".", "prototype", ",", "name", ",", "meta", ")", ")", "{", "this", ".", "_events_", ".", "push", "(", "name", ")", ";", "}", "return", "this", ";", "}" ]
Define an event. @method defineEvent @static @param name {String} @param [meta] {Object} @param [target] {Object}
[ "Define", "an", "event", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1157-L1163
37,535
yangyxu/zeanium
dist/zn.reactnative.js
function (name, meta, target) { if (!__define.defineProperty(target || this.prototype, name, meta)) { this._properties_.push(name); } return this; }
javascript
function (name, meta, target) { if (!__define.defineProperty(target || this.prototype, name, meta)) { this._properties_.push(name); } return this; }
[ "function", "(", "name", ",", "meta", ",", "target", ")", "{", "if", "(", "!", "__define", ".", "defineProperty", "(", "target", "||", "this", ".", "prototype", ",", "name", ",", "meta", ")", ")", "{", "this", ".", "_properties_", ".", "push", "(", "name", ")", ";", "}", "return", "this", ";", "}" ]
Define a property. @method defineProperty @static @param name {String} @param [meta] {Object} @param [target] {Object}
[ "Define", "a", "property", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1172-L1178
37,536
yangyxu/zeanium
dist/zn.reactnative.js
function (name, meta, target) { if (!__define.defineMethod(target || this.prototype, name, meta)) { this._methods_.push(name); } return this; }
javascript
function (name, meta, target) { if (!__define.defineMethod(target || this.prototype, name, meta)) { this._methods_.push(name); } return this; }
[ "function", "(", "name", ",", "meta", ",", "target", ")", "{", "if", "(", "!", "__define", ".", "defineMethod", "(", "target", "||", "this", ".", "prototype", ",", "name", ",", "meta", ")", ")", "{", "this", ".", "_methods_", ".", "push", "(", "name", ")", ";", "}", "return", "this", ";", "}" ]
Define a method. @method defineMethod @static @param name {String} @param meta {Object} @param [target] {Object}
[ "Define", "a", "method", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1187-L1193
37,537
yangyxu/zeanium
dist/zn.reactnative.js
function (){ var _info = { ClassName: (this.__name__ || 'Anonymous'), InstanceID: this.__id__, Meta: this.constructor._meta_ }; return JSON.stringify(_info); }
javascript
function (){ var _info = { ClassName: (this.__name__ || 'Anonymous'), InstanceID: this.__id__, Meta: this.constructor._meta_ }; return JSON.stringify(_info); }
[ "function", "(", ")", "{", "var", "_info", "=", "{", "ClassName", ":", "(", "this", ".", "__name__", "||", "'Anonymous'", ")", ",", "InstanceID", ":", "this", ".", "__id__", ",", "Meta", ":", "this", ".", "constructor", ".", "_meta_", "}", ";", "return", "JSON", ".", "stringify", "(", "_info", ")", ";", "}" ]
Instance Object to string value. @returns {string}
[ "Instance", "Object", "to", "string", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1201-L1208
37,538
yangyxu/zeanium
dist/zn.reactnative.js
function (){ var _json = {}; zn.each(this.constructor.getProperties(), function (field, key){ _json[key] = this.get(key); }, this); return _json; }
javascript
function (){ var _json = {}; zn.each(this.constructor.getProperties(), function (field, key){ _json[key] = this.get(key); }, this); return _json; }
[ "function", "(", ")", "{", "var", "_json", "=", "{", "}", ";", "zn", ".", "each", "(", "this", ".", "constructor", ".", "getProperties", "(", ")", ",", "function", "(", "field", ",", "key", ")", "{", "_json", "[", "key", "]", "=", "this", ".", "get", "(", "key", ")", ";", "}", ",", "this", ")", ";", "return", "_json", ";", "}" ]
Instance Object to json value. @returns {json}
[ "Instance", "Object", "to", "json", "value", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1213-L1220
37,539
yangyxu/zeanium
dist/zn.reactnative.js
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = zn.extend({ owner: this, handler: handler }, options); } return this; }
javascript
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || []; _listeners[0] = zn.extend({ owner: this, handler: handler }, options); } return this; }
[ "function", "(", "name", ",", "handler", ",", "options", ")", "{", "if", "(", "handler", ")", "{", "var", "_handlers", "=", "this", ".", "__handlers__", ";", "var", "_listeners", "=", "_handlers", "[", "name", "]", "=", "_handlers", "[", "name", "]", "||", "[", "]", ";", "_listeners", "[", "0", "]", "=", "zn", ".", "extend", "(", "{", "owner", ":", "this", ",", "handler", ":", "handler", "}", ",", "options", ")", ";", "}", "return", "this", ";", "}" ]
Add a single event handler. @method upon @param name {String} @param handler {Function} @param [options] {Object}
[ "Add", "a", "single", "event", "handler", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1234-L1246
37,540
yangyxu/zeanium
dist/zn.reactnative.js
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || [ { owner: null, handler: null, context: null } ]; _listeners.push(zn.extend({ owner: this, handler: handler }, options)); } return this; }
javascript
function (name, handler, options) { if (handler) { var _handlers = this.__handlers__; var _listeners = _handlers[name] = _handlers[name] || [ { owner: null, handler: null, context: null } ]; _listeners.push(zn.extend({ owner: this, handler: handler }, options)); } return this; }
[ "function", "(", "name", ",", "handler", ",", "options", ")", "{", "if", "(", "handler", ")", "{", "var", "_handlers", "=", "this", ".", "__handlers__", ";", "var", "_listeners", "=", "_handlers", "[", "name", "]", "=", "_handlers", "[", "name", "]", "||", "[", "{", "owner", ":", "null", ",", "handler", ":", "null", ",", "context", ":", "null", "}", "]", ";", "_listeners", ".", "push", "(", "zn", ".", "extend", "(", "{", "owner", ":", "this", ",", "handler", ":", "handler", "}", ",", "options", ")", ")", ";", "}", "return", "this", ";", "}" ]
Add an event handler. @method on @param name {String} @param handler {Function} @param [options] {Object}
[ "Add", "an", "event", "handler", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1254-L1272
37,541
yangyxu/zeanium
dist/zn.reactnative.js
function (name, handler, options) { var _listeners = this.__handlers__[name]||[], _listener; var _context = options && options.context; if (handler) { for (var i = _listeners.length - 1; i >= 0; i--) { _listener = _listeners[i]; if (_listener.handler === handler && (!_context || _listener.context === _context )) { this.__handlers__[name].splice(i, 1); } } } else { this.__handlers__[name] = [ { owner: null, handler: null, context: null } ]; } return this; }
javascript
function (name, handler, options) { var _listeners = this.__handlers__[name]||[], _listener; var _context = options && options.context; if (handler) { for (var i = _listeners.length - 1; i >= 0; i--) { _listener = _listeners[i]; if (_listener.handler === handler && (!_context || _listener.context === _context )) { this.__handlers__[name].splice(i, 1); } } } else { this.__handlers__[name] = [ { owner: null, handler: null, context: null } ]; } return this; }
[ "function", "(", "name", ",", "handler", ",", "options", ")", "{", "var", "_listeners", "=", "this", ".", "__handlers__", "[", "name", "]", "||", "[", "]", ",", "_listener", ";", "var", "_context", "=", "options", "&&", "options", ".", "context", ";", "if", "(", "handler", ")", "{", "for", "(", "var", "i", "=", "_listeners", ".", "length", "-", "1", ";", "i", ">=", "0", ";", "i", "--", ")", "{", "_listener", "=", "_listeners", "[", "i", "]", ";", "if", "(", "_listener", ".", "handler", "===", "handler", "&&", "(", "!", "_context", "||", "_listener", ".", "context", "===", "_context", ")", ")", "{", "this", ".", "__handlers__", "[", "name", "]", ".", "splice", "(", "i", ",", "1", ")", ";", "}", "}", "}", "else", "{", "this", ".", "__handlers__", "[", "name", "]", "=", "[", "{", "owner", ":", "null", ",", "handler", ":", "null", ",", "context", ":", "null", "}", "]", ";", "}", "return", "this", ";", "}" ]
Remove an event handler. @method off @param name {String} @param [handler] {Function} @param [options] {Object}
[ "Remove", "an", "event", "handler", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1280-L1302
37,542
yangyxu/zeanium
dist/zn.reactnative.js
function (name, data, options) { var _listeners = this.__handlers__[name], _listener, _result = null; if (_listeners) { for (var i = 0, length = _listeners.length; i < length; i++) { _listener = _listeners[i]; if (_listener && _listener.handler) { if(options && options.method=='apply'){ _result = _listener.handler.apply(_listener.context || _listener.owner, data); } else { _result = _listener.handler.call(_listener.context || _listener.owner, _listener.owner, data, options); } if (false === _result) { return false; } } } } return this; }
javascript
function (name, data, options) { var _listeners = this.__handlers__[name], _listener, _result = null; if (_listeners) { for (var i = 0, length = _listeners.length; i < length; i++) { _listener = _listeners[i]; if (_listener && _listener.handler) { if(options && options.method=='apply'){ _result = _listener.handler.apply(_listener.context || _listener.owner, data); } else { _result = _listener.handler.call(_listener.context || _listener.owner, _listener.owner, data, options); } if (false === _result) { return false; } } } } return this; }
[ "function", "(", "name", ",", "data", ",", "options", ")", "{", "var", "_listeners", "=", "this", ".", "__handlers__", "[", "name", "]", ",", "_listener", ",", "_result", "=", "null", ";", "if", "(", "_listeners", ")", "{", "for", "(", "var", "i", "=", "0", ",", "length", "=", "_listeners", ".", "length", ";", "i", "<", "length", ";", "i", "++", ")", "{", "_listener", "=", "_listeners", "[", "i", "]", ";", "if", "(", "_listener", "&&", "_listener", ".", "handler", ")", "{", "if", "(", "options", "&&", "options", ".", "method", "==", "'apply'", ")", "{", "_result", "=", "_listener", ".", "handler", ".", "apply", "(", "_listener", ".", "context", "||", "_listener", ".", "owner", ",", "data", ")", ";", "}", "else", "{", "_result", "=", "_listener", ".", "handler", ".", "call", "(", "_listener", ".", "context", "||", "_listener", ".", "owner", ",", "_listener", ".", "owner", ",", "data", ",", "options", ")", ";", "}", "if", "(", "false", "===", "_result", ")", "{", "return", "false", ";", "}", "}", "}", "}", "return", "this", ";", "}" ]
Trigger an event. @method fire @param name {String} @param [data] {*} @param [options] {Object}
[ "Trigger", "an", "event", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1330-L1351
37,543
yangyxu/zeanium
dist/zn.reactnative.js
function (type) { if (typeof type === 'string') { type = zn.path(GLOBAL, type); } if (type) { if (this instanceof type) { return true; } else { var _mixins = this.constructor._mixins_; for (var i = 0, _len = _mixins.length; i < _len; i++) { var _mixin = _mixins[i]; if (type === _mixin) { return true; } } } } return false; }
javascript
function (type) { if (typeof type === 'string') { type = zn.path(GLOBAL, type); } if (type) { if (this instanceof type) { return true; } else { var _mixins = this.constructor._mixins_; for (var i = 0, _len = _mixins.length; i < _len; i++) { var _mixin = _mixins[i]; if (type === _mixin) { return true; } } } } return false; }
[ "function", "(", "type", ")", "{", "if", "(", "typeof", "type", "===", "'string'", ")", "{", "type", "=", "zn", ".", "path", "(", "GLOBAL", ",", "type", ")", ";", "}", "if", "(", "type", ")", "{", "if", "(", "this", "instanceof", "type", ")", "{", "return", "true", ";", "}", "else", "{", "var", "_mixins", "=", "this", ".", "constructor", ".", "_mixins_", ";", "for", "(", "var", "i", "=", "0", ",", "_len", "=", "_mixins", ".", "length", ";", "i", "<", "_len", ";", "i", "++", ")", "{", "var", "_mixin", "=", "_mixins", "[", "i", "]", ";", "if", "(", "type", "===", "_mixin", ")", "{", "return", "true", ";", "}", "}", "}", "}", "return", "false", ";", "}" ]
Check whether current object is specified type. @method is @param type {String|Function} @returns {Boolean}
[ "Check", "whether", "current", "object", "is", "specified", "type", "." ]
8465e744654cea7a55be623fd440abb079a5309f
https://github.com/yangyxu/zeanium/blob/8465e744654cea7a55be623fd440abb079a5309f/dist/zn.reactnative.js#L1382-L1402
37,544
eswdd/aardvark
static-content/ScatterRenderer.js
function(into, data) { var existingDataLen = into.length == 0 ? 0 : into[0].length - 1; var i = 0; var j = 0; for (; i<into.length && j<data.length; ) { if (into[i][0] == data[j][0]) { into[i].push(data[j][1]); i++; j++; } else if (into[i][0] < data[j][0]) { into[i].push(null); i++; } else { var arr = [data[j][0]]; for (var k=1; k<into[i].length; k++) { arr.push(null); } arr.push(data[j][1]); into.splice(i,0,arr); i++; j++; } } while (j<data.length) { var arr = [data[j][0]]; for (var k=0; k<existingDataLen; k++) { arr.push(null); } arr.push(data[j][1]); into.push(arr); j++; } }
javascript
function(into, data) { var existingDataLen = into.length == 0 ? 0 : into[0].length - 1; var i = 0; var j = 0; for (; i<into.length && j<data.length; ) { if (into[i][0] == data[j][0]) { into[i].push(data[j][1]); i++; j++; } else if (into[i][0] < data[j][0]) { into[i].push(null); i++; } else { var arr = [data[j][0]]; for (var k=1; k<into[i].length; k++) { arr.push(null); } arr.push(data[j][1]); into.splice(i,0,arr); i++; j++; } } while (j<data.length) { var arr = [data[j][0]]; for (var k=0; k<existingDataLen; k++) { arr.push(null); } arr.push(data[j][1]); into.push(arr); j++; } }
[ "function", "(", "into", ",", "data", ")", "{", "var", "existingDataLen", "=", "into", ".", "length", "==", "0", "?", "0", ":", "into", "[", "0", "]", ".", "length", "-", "1", ";", "var", "i", "=", "0", ";", "var", "j", "=", "0", ";", "for", "(", ";", "i", "<", "into", ".", "length", "&&", "j", "<", "data", ".", "length", ";", ")", "{", "if", "(", "into", "[", "i", "]", "[", "0", "]", "==", "data", "[", "j", "]", "[", "0", "]", ")", "{", "into", "[", "i", "]", ".", "push", "(", "data", "[", "j", "]", "[", "1", "]", ")", ";", "i", "++", ";", "j", "++", ";", "}", "else", "if", "(", "into", "[", "i", "]", "[", "0", "]", "<", "data", "[", "j", "]", "[", "0", "]", ")", "{", "into", "[", "i", "]", ".", "push", "(", "null", ")", ";", "i", "++", ";", "}", "else", "{", "var", "arr", "=", "[", "data", "[", "j", "]", "[", "0", "]", "]", ";", "for", "(", "var", "k", "=", "1", ";", "k", "<", "into", "[", "i", "]", ".", "length", ";", "k", "++", ")", "{", "arr", ".", "push", "(", "null", ")", ";", "}", "arr", ".", "push", "(", "data", "[", "j", "]", "[", "1", "]", ")", ";", "into", ".", "splice", "(", "i", ",", "0", ",", "arr", ")", ";", "i", "++", ";", "j", "++", ";", "}", "}", "while", "(", "j", "<", "data", ".", "length", ")", "{", "var", "arr", "=", "[", "data", "[", "j", "]", "[", "0", "]", "]", ";", "for", "(", "var", "k", "=", "0", ";", "k", "<", "existingDataLen", ";", "k", "++", ")", "{", "arr", ".", "push", "(", "null", ")", ";", "}", "arr", ".", "push", "(", "data", "[", "j", "]", "[", "1", "]", ")", ";", "into", ".", "push", "(", "arr", ")", ";", "j", "++", ";", "}", "}" ]
should both be sorted already
[ "should", "both", "be", "sorted", "already" ]
7e0797fe5cde53047e610bd866d22e6caf0c6d49
https://github.com/eswdd/aardvark/blob/7e0797fe5cde53047e610bd866d22e6caf0c6d49/static-content/ScatterRenderer.js#L208-L242
37,545
quentinrossetti/version-sort
index.js
composeVersion
function composeVersion (str, regex) { var r = regex.exec(str) return { number: r[ 1 ], stage: r[ 2 ] || null, stageName: r[ 3 ] || null, stageNumber: r[ 4 ] || null } }
javascript
function composeVersion (str, regex) { var r = regex.exec(str) return { number: r[ 1 ], stage: r[ 2 ] || null, stageName: r[ 3 ] || null, stageNumber: r[ 4 ] || null } }
[ "function", "composeVersion", "(", "str", ",", "regex", ")", "{", "var", "r", "=", "regex", ".", "exec", "(", "str", ")", "return", "{", "number", ":", "r", "[", "1", "]", ",", "stage", ":", "r", "[", "2", "]", "||", "null", ",", "stageName", ":", "r", "[", "3", "]", "||", "null", ",", "stageNumber", ":", "r", "[", "4", "]", "||", "null", "}", "}" ]
Transform a string into an exploitable version object. @param str The original string @returns {{number: *, stage: (*|null), stageName: (*|null), stageNumber: (*|null)}}
[ "Transform", "a", "string", "into", "an", "exploitable", "version", "object", "." ]
3e8855216f14f12e99497bd487355c06076ceedc
https://github.com/quentinrossetti/version-sort/blob/3e8855216f14f12e99497bd487355c06076ceedc/index.js#L167-L175
37,546
cevadtokatli/cordelia
dist/js/cordelia.esm.js
createEvent
function createEvent(name) { var event = void 0; if (typeof document !== 'undefined') { event = document.createEvent('HTMLEvents') || document.createEvent('event'); event.initEvent(name, false, true); } return event; }
javascript
function createEvent(name) { var event = void 0; if (typeof document !== 'undefined') { event = document.createEvent('HTMLEvents') || document.createEvent('event'); event.initEvent(name, false, true); } return event; }
[ "function", "createEvent", "(", "name", ")", "{", "var", "event", "=", "void", "0", ";", "if", "(", "typeof", "document", "!==", "'undefined'", ")", "{", "event", "=", "document", ".", "createEvent", "(", "'HTMLEvents'", ")", "||", "document", ".", "createEvent", "(", "'event'", ")", ";", "event", ".", "initEvent", "(", "name", ",", "false", ",", "true", ")", ";", "}", "return", "event", ";", "}" ]
Creates a new event and initalizes it. @param {String} name @returns {Event}
[ "Creates", "a", "new", "event", "and", "initalizes", "it", "." ]
ac2c66c6844b28d3bf9ceb2c4c22b20bda0fc5ca
https://github.com/cevadtokatli/cordelia/blob/ac2c66c6844b28d3bf9ceb2c4c22b20bda0fc5ca/dist/js/cordelia.esm.js#L1229-L1236
37,547
eswdd/aardvark
static-content/DeepUtils.js
function(target, skeleton) { // console.log("Applying change: "+JSON.stringify(skeleton)); if (skeleton == null) { return false; } if (typeof skeleton != typeof target) { return false; } switch (typeof skeleton) { case 'string': case 'number': case 'boolean': // gone too far return false; case 'object': if (skeleton instanceof Array) { // for now only support direct replacement/mutation of elements, skeleton is insufficient to describe splicing if (target.length != skeleton.length) { return false; } var changed = false; for (var i=0; i<skeleton.length; i++) { if (skeleton[i] == null) { continue; } switch (typeof skeleton[i]) { case 'string': case 'number': case 'boolean': changed = (target[i] != skeleton[i]) || changed; target[i] = skeleton[i]; break; case 'object': changed = deepApply(target[i], skeleton[i]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[i]); } } return changed; } else { var changed = false; for (var k in skeleton) { if (skeleton.hasOwnProperty(k)) { if (target.hasOwnProperty(k)) { if (skeleton[k] == null) { continue; } switch (typeof skeleton[k]) { case 'string': case 'number': case 'boolean': changed = target[k] != skeleton[k] || changed; target[k] = skeleton[k]; break; case 'object': changed = deepApply(target[k], skeleton[k]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[k]); } } else { target[k] = skeleton[k]; } } } return changed; } break; default: throw 'Unrecognized type: '+(typeof incoming); } }
javascript
function(target, skeleton) { // console.log("Applying change: "+JSON.stringify(skeleton)); if (skeleton == null) { return false; } if (typeof skeleton != typeof target) { return false; } switch (typeof skeleton) { case 'string': case 'number': case 'boolean': // gone too far return false; case 'object': if (skeleton instanceof Array) { // for now only support direct replacement/mutation of elements, skeleton is insufficient to describe splicing if (target.length != skeleton.length) { return false; } var changed = false; for (var i=0; i<skeleton.length; i++) { if (skeleton[i] == null) { continue; } switch (typeof skeleton[i]) { case 'string': case 'number': case 'boolean': changed = (target[i] != skeleton[i]) || changed; target[i] = skeleton[i]; break; case 'object': changed = deepApply(target[i], skeleton[i]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[i]); } } return changed; } else { var changed = false; for (var k in skeleton) { if (skeleton.hasOwnProperty(k)) { if (target.hasOwnProperty(k)) { if (skeleton[k] == null) { continue; } switch (typeof skeleton[k]) { case 'string': case 'number': case 'boolean': changed = target[k] != skeleton[k] || changed; target[k] = skeleton[k]; break; case 'object': changed = deepApply(target[k], skeleton[k]) || changed; break; default: throw 'Unrecognized type: '+(typeof skeleton[k]); } } else { target[k] = skeleton[k]; } } } return changed; } break; default: throw 'Unrecognized type: '+(typeof incoming); } }
[ "function", "(", "target", ",", "skeleton", ")", "{", "// console.log(\"Applying change: \"+JSON.stringify(skeleton));", "if", "(", "skeleton", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "typeof", "skeleton", "!=", "typeof", "target", ")", "{", "return", "false", ";", "}", "switch", "(", "typeof", "skeleton", ")", "{", "case", "'string'", ":", "case", "'number'", ":", "case", "'boolean'", ":", "// gone too far", "return", "false", ";", "case", "'object'", ":", "if", "(", "skeleton", "instanceof", "Array", ")", "{", "// for now only support direct replacement/mutation of elements, skeleton is insufficient to describe splicing", "if", "(", "target", ".", "length", "!=", "skeleton", ".", "length", ")", "{", "return", "false", ";", "}", "var", "changed", "=", "false", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "skeleton", ".", "length", ";", "i", "++", ")", "{", "if", "(", "skeleton", "[", "i", "]", "==", "null", ")", "{", "continue", ";", "}", "switch", "(", "typeof", "skeleton", "[", "i", "]", ")", "{", "case", "'string'", ":", "case", "'number'", ":", "case", "'boolean'", ":", "changed", "=", "(", "target", "[", "i", "]", "!=", "skeleton", "[", "i", "]", ")", "||", "changed", ";", "target", "[", "i", "]", "=", "skeleton", "[", "i", "]", ";", "break", ";", "case", "'object'", ":", "changed", "=", "deepApply", "(", "target", "[", "i", "]", ",", "skeleton", "[", "i", "]", ")", "||", "changed", ";", "break", ";", "default", ":", "throw", "'Unrecognized type: '", "+", "(", "typeof", "skeleton", "[", "i", "]", ")", ";", "}", "}", "return", "changed", ";", "}", "else", "{", "var", "changed", "=", "false", ";", "for", "(", "var", "k", "in", "skeleton", ")", "{", "if", "(", "skeleton", ".", "hasOwnProperty", "(", "k", ")", ")", "{", "if", "(", "target", ".", "hasOwnProperty", "(", "k", ")", ")", "{", "if", "(", "skeleton", "[", "k", "]", "==", "null", ")", "{", "continue", ";", "}", "switch", "(", "typeof", "skeleton", "[", "k", "]", ")", "{", "case", "'string'", ":", "case", "'number'", ":", "case", "'boolean'", ":", "changed", "=", "target", "[", "k", "]", "!=", "skeleton", "[", "k", "]", "||", "changed", ";", "target", "[", "k", "]", "=", "skeleton", "[", "k", "]", ";", "break", ";", "case", "'object'", ":", "changed", "=", "deepApply", "(", "target", "[", "k", "]", ",", "skeleton", "[", "k", "]", ")", "||", "changed", ";", "break", ";", "default", ":", "throw", "'Unrecognized type: '", "+", "(", "typeof", "skeleton", "[", "k", "]", ")", ";", "}", "}", "else", "{", "target", "[", "k", "]", "=", "skeleton", "[", "k", "]", ";", "}", "}", "}", "return", "changed", ";", "}", "break", ";", "default", ":", "throw", "'Unrecognized type: '", "+", "(", "typeof", "incoming", ")", ";", "}", "}" ]
Deep applies a skeleton change to the target object
[ "Deep", "applies", "a", "skeleton", "change", "to", "the", "target", "object" ]
7e0797fe5cde53047e610bd866d22e6caf0c6d49
https://github.com/eswdd/aardvark/blob/7e0797fe5cde53047e610bd866d22e6caf0c6d49/static-content/DeepUtils.js#L50-L126
37,548
solid/source-pane
sourcePane.js
function (newPaneOptions) { var newInstance = newPaneOptions.newInstance if (!newInstance) { let uri = newPaneOptions.newBase if (uri.endsWith('/')) { uri = uri.slice(0, -1) newPaneOptions.newBase = uri } newInstance = kb.sym(uri) newPaneOptions.newInstance = newInstance } var contentType = mime.lookup(newInstance.uri) if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) { let msg = 'A new text file has to have an file extension like .txt .ttl etc.' alert(msg) throw new Error(msg) } return new Promise(function (resolve, reject) { kb.fetcher.webOperation('PUT', newInstance.uri, {data: '\n', contentType: contentType}) .then(function (response) { console.log('New text file created: ' + newInstance.uri) newPaneOptions.newInstance = newInstance resolve(newPaneOptions) }, err => { alert('Cant make new file: ' + err) reject(err) }) }) }
javascript
function (newPaneOptions) { var newInstance = newPaneOptions.newInstance if (!newInstance) { let uri = newPaneOptions.newBase if (uri.endsWith('/')) { uri = uri.slice(0, -1) newPaneOptions.newBase = uri } newInstance = kb.sym(uri) newPaneOptions.newInstance = newInstance } var contentType = mime.lookup(newInstance.uri) if (!contentType || !(contentType.startsWith('text') || contentType.includes('xml'))) { let msg = 'A new text file has to have an file extension like .txt .ttl etc.' alert(msg) throw new Error(msg) } return new Promise(function (resolve, reject) { kb.fetcher.webOperation('PUT', newInstance.uri, {data: '\n', contentType: contentType}) .then(function (response) { console.log('New text file created: ' + newInstance.uri) newPaneOptions.newInstance = newInstance resolve(newPaneOptions) }, err => { alert('Cant make new file: ' + err) reject(err) }) }) }
[ "function", "(", "newPaneOptions", ")", "{", "var", "newInstance", "=", "newPaneOptions", ".", "newInstance", "if", "(", "!", "newInstance", ")", "{", "let", "uri", "=", "newPaneOptions", ".", "newBase", "if", "(", "uri", ".", "endsWith", "(", "'/'", ")", ")", "{", "uri", "=", "uri", ".", "slice", "(", "0", ",", "-", "1", ")", "newPaneOptions", ".", "newBase", "=", "uri", "}", "newInstance", "=", "kb", ".", "sym", "(", "uri", ")", "newPaneOptions", ".", "newInstance", "=", "newInstance", "}", "var", "contentType", "=", "mime", ".", "lookup", "(", "newInstance", ".", "uri", ")", "if", "(", "!", "contentType", "||", "!", "(", "contentType", ".", "startsWith", "(", "'text'", ")", "||", "contentType", ".", "includes", "(", "'xml'", ")", ")", ")", "{", "let", "msg", "=", "'A new text file has to have an file extension like .txt .ttl etc.'", "alert", "(", "msg", ")", "throw", "new", "Error", "(", "msg", ")", "}", "return", "new", "Promise", "(", "function", "(", "resolve", ",", "reject", ")", "{", "kb", ".", "fetcher", ".", "webOperation", "(", "'PUT'", ",", "newInstance", ".", "uri", ",", "{", "data", ":", "'\\n'", ",", "contentType", ":", "contentType", "}", ")", ".", "then", "(", "function", "(", "response", ")", "{", "console", ".", "log", "(", "'New text file created: '", "+", "newInstance", ".", "uri", ")", "newPaneOptions", ".", "newInstance", "=", "newInstance", "resolve", "(", "newPaneOptions", ")", "}", ",", "err", "=>", "{", "alert", "(", "'Cant make new file: '", "+", "err", ")", "reject", "(", "err", ")", "}", ")", "}", ")", "}" ]
Create a new text file in a Solid system,
[ "Create", "a", "new", "text", "file", "in", "a", "Solid", "system" ]
cd7803323fd79016c78eac08000faf0d40d285cf
https://github.com/solid/source-pane/blob/cd7803323fd79016c78eac08000faf0d40d285cf/sourcePane.js#L28-L58
37,549
jamiebuilds/graph-sequencer
index.js
visit
function visit(item, cycle) { let visitedDeps = visited.get(item); // Create an object for the item to mark visited deps. if (!visitedDeps) { visitedDeps = []; visited.set(item, visitedDeps); } // Get the current deps for the item. let deps = currDepsMap.get(item); if (typeof deps === 'undefined') return; // For each dep, for (let dep of deps) { // Check if this dep creates a cycle. We know it's a cycle if the first // item is the same as our dep. if (cycle[0] === dep) { cycles.push(cycle); } // If an item hasn't been visited, visit it (and pass an updated // potential cycle) if (!arrayIncludes(visitedDeps, dep)) { visitedDeps.push(dep); visit(dep, cycle.concat(dep)); } } }
javascript
function visit(item, cycle) { let visitedDeps = visited.get(item); // Create an object for the item to mark visited deps. if (!visitedDeps) { visitedDeps = []; visited.set(item, visitedDeps); } // Get the current deps for the item. let deps = currDepsMap.get(item); if (typeof deps === 'undefined') return; // For each dep, for (let dep of deps) { // Check if this dep creates a cycle. We know it's a cycle if the first // item is the same as our dep. if (cycle[0] === dep) { cycles.push(cycle); } // If an item hasn't been visited, visit it (and pass an updated // potential cycle) if (!arrayIncludes(visitedDeps, dep)) { visitedDeps.push(dep); visit(dep, cycle.concat(dep)); } } }
[ "function", "visit", "(", "item", ",", "cycle", ")", "{", "let", "visitedDeps", "=", "visited", ".", "get", "(", "item", ")", ";", "// Create an object for the item to mark visited deps.", "if", "(", "!", "visitedDeps", ")", "{", "visitedDeps", "=", "[", "]", ";", "visited", ".", "set", "(", "item", ",", "visitedDeps", ")", ";", "}", "// Get the current deps for the item.", "let", "deps", "=", "currDepsMap", ".", "get", "(", "item", ")", ";", "if", "(", "typeof", "deps", "===", "'undefined'", ")", "return", ";", "// For each dep,", "for", "(", "let", "dep", "of", "deps", ")", "{", "// Check if this dep creates a cycle. We know it's a cycle if the first", "// item is the same as our dep.", "if", "(", "cycle", "[", "0", "]", "===", "dep", ")", "{", "cycles", ".", "push", "(", "cycle", ")", ";", "}", "// If an item hasn't been visited, visit it (and pass an updated", "// potential cycle)", "if", "(", "!", "arrayIncludes", "(", "visitedDeps", ",", "dep", ")", ")", "{", "visitedDeps", ".", "push", "(", "dep", ")", ";", "visit", "(", "dep", ",", "cycle", ".", "concat", "(", "dep", ")", ")", ";", "}", "}", "}" ]
Create a function to call recursively in a depth-first search.
[ "Create", "a", "function", "to", "call", "recursively", "in", "a", "depth", "-", "first", "search", "." ]
565c024a02a1e3b83758149a2fd4eeb24753a898
https://github.com/jamiebuilds/graph-sequencer/blob/565c024a02a1e3b83758149a2fd4eeb24753a898/index.js#L32-L60
37,550
botmasterai/node-red-contrib-botmaster
dist/botmaster.js
setupBotStatus
function setupBotStatus(bot, node) { var updates = 0; var replies = 0; var updateText = function updateText() { return updates !== 1 ? updates + ' updates' : updates + ' update'; }; var replyText= function replyText() { return replies !== 1 ? replies + ' replies': replies + ' reply'; }; var updateStatus = function updateStatus() { node.status({fill: 'green', shape: 'dot', text: updateText() + '; ' + replyText() }); }; node.status({fill: 'grey', shape: 'ring', text: 'inactive'}); bot.on('update', function updateCallback() { updates += 1; updateStatus(); }); bot.on('error', function errorCallback(error) { node.error(error); node.status({fill: 'red', shape: 'dot', text: 'error'}); }); bot.use('outgoing', function outgoingCallback(bot, update, message, next) { replies += 1; updateStatus(); next(); }); }
javascript
function setupBotStatus(bot, node) { var updates = 0; var replies = 0; var updateText = function updateText() { return updates !== 1 ? updates + ' updates' : updates + ' update'; }; var replyText= function replyText() { return replies !== 1 ? replies + ' replies': replies + ' reply'; }; var updateStatus = function updateStatus() { node.status({fill: 'green', shape: 'dot', text: updateText() + '; ' + replyText() }); }; node.status({fill: 'grey', shape: 'ring', text: 'inactive'}); bot.on('update', function updateCallback() { updates += 1; updateStatus(); }); bot.on('error', function errorCallback(error) { node.error(error); node.status({fill: 'red', shape: 'dot', text: 'error'}); }); bot.use('outgoing', function outgoingCallback(bot, update, message, next) { replies += 1; updateStatus(); next(); }); }
[ "function", "setupBotStatus", "(", "bot", ",", "node", ")", "{", "var", "updates", "=", "0", ";", "var", "replies", "=", "0", ";", "var", "updateText", "=", "function", "updateText", "(", ")", "{", "return", "updates", "!==", "1", "?", "updates", "+", "' updates'", ":", "updates", "+", "' update'", ";", "}", ";", "var", "replyText", "=", "function", "replyText", "(", ")", "{", "return", "replies", "!==", "1", "?", "replies", "+", "' replies'", ":", "replies", "+", "' reply'", ";", "}", ";", "var", "updateStatus", "=", "function", "updateStatus", "(", ")", "{", "node", ".", "status", "(", "{", "fill", ":", "'green'", ",", "shape", ":", "'dot'", ",", "text", ":", "updateText", "(", ")", "+", "'; '", "+", "replyText", "(", ")", "}", ")", ";", "}", ";", "node", ".", "status", "(", "{", "fill", ":", "'grey'", ",", "shape", ":", "'ring'", ",", "text", ":", "'inactive'", "}", ")", ";", "bot", ".", "on", "(", "'update'", ",", "function", "updateCallback", "(", ")", "{", "updates", "+=", "1", ";", "updateStatus", "(", ")", ";", "}", ")", ";", "bot", ".", "on", "(", "'error'", ",", "function", "errorCallback", "(", "error", ")", "{", "node", ".", "error", "(", "error", ")", ";", "node", ".", "status", "(", "{", "fill", ":", "'red'", ",", "shape", ":", "'dot'", ",", "text", ":", "'error'", "}", ")", ";", "}", ")", ";", "bot", ".", "use", "(", "'outgoing'", ",", "function", "outgoingCallback", "(", "bot", ",", "update", ",", "message", ",", "next", ")", "{", "replies", "+=", "1", ";", "updateStatus", "(", ")", ";", "next", "(", ")", ";", "}", ")", ";", "}" ]
Show a little status next to each configured bot
[ "Show", "a", "little", "status", "next", "to", "each", "configured", "bot" ]
8a42897b15f7f99c1e7989ea9eacc3eceefa0905
https://github.com/botmasterai/node-red-contrib-botmaster/blob/8a42897b15f7f99c1e7989ea9eacc3eceefa0905/dist/botmaster.js#L57-L87
37,551
scienceai/jsonld-rdfa-parser
src/index.js
processGraph
function processGraph(data) { let dataset = { '@default': [] }; let subjects = data.subjects, htmlMapper = n => { let div = n.ownerDocument.createElement('div'); div.appendChild(n.cloneNode(true)); return div.innerHTML; }; Object.keys(subjects).forEach(subject => { let predicates = subjects[subject].predicates; Object.keys(predicates).forEach(predicate => { // iterate over objects let objects = predicates[predicate].objects; for (let oi = 0; oi < objects.length; ++oi) { let object = objects[oi]; // create RDF triple let triple = {}; // add subject & predicate triple.subject = { type: subject.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: subject }; triple.predicate = { type: predicate.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: predicate }; triple.object = {}; // serialize XML literal let value = object.value; // !!! TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // The below actually most likely does NOT work. // In most usage contexts this will be an HTML DOM, passing it to xmldom's XMLSerializer // will cause it to call .toString() on all the nodes it finds — this only works inside // xmldom. if (object.type === RDF_XML_LITERAL) { // initialize XMLSerializer let serializer = new XMLSerializer(); value = Array.from(object.value) .map(n => serializer.serializeToString(n)) .join(''); triple.object.datatype = RDF_XML_LITERAL; } // serialise HTML literal else if (object.type === RDF_HTML_LITERAL) { value = Array.from(object.value) .map(htmlMapper) .join(''); triple.object.datatype = RDF_HTML_LITERAL; } // object is an IRI else if (object.type === RDF_OBJECT) { if (object.value.indexOf('_:') === 0) triple.object.type = 'blank node'; else triple.object.type = 'IRI'; } else { // object is a literal triple.object.type = 'literal'; if (object.type === RDF_PLAIN_LITERAL) { if (object.language) { triple.object.datatype = RDF_LANGSTRING; triple.object.language = object.language; } else { triple.object.datatype = XSD_STRING; } } else { triple.object.datatype = object.type; } } triple.object.value = value; // add triple to dataset in default graph dataset['@default'].push(triple); } }); }); return dataset; }
javascript
function processGraph(data) { let dataset = { '@default': [] }; let subjects = data.subjects, htmlMapper = n => { let div = n.ownerDocument.createElement('div'); div.appendChild(n.cloneNode(true)); return div.innerHTML; }; Object.keys(subjects).forEach(subject => { let predicates = subjects[subject].predicates; Object.keys(predicates).forEach(predicate => { // iterate over objects let objects = predicates[predicate].objects; for (let oi = 0; oi < objects.length; ++oi) { let object = objects[oi]; // create RDF triple let triple = {}; // add subject & predicate triple.subject = { type: subject.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: subject }; triple.predicate = { type: predicate.indexOf('_:') === 0 ? 'blank node' : 'IRI', value: predicate }; triple.object = {}; // serialize XML literal let value = object.value; // !!! TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // The below actually most likely does NOT work. // In most usage contexts this will be an HTML DOM, passing it to xmldom's XMLSerializer // will cause it to call .toString() on all the nodes it finds — this only works inside // xmldom. if (object.type === RDF_XML_LITERAL) { // initialize XMLSerializer let serializer = new XMLSerializer(); value = Array.from(object.value) .map(n => serializer.serializeToString(n)) .join(''); triple.object.datatype = RDF_XML_LITERAL; } // serialise HTML literal else if (object.type === RDF_HTML_LITERAL) { value = Array.from(object.value) .map(htmlMapper) .join(''); triple.object.datatype = RDF_HTML_LITERAL; } // object is an IRI else if (object.type === RDF_OBJECT) { if (object.value.indexOf('_:') === 0) triple.object.type = 'blank node'; else triple.object.type = 'IRI'; } else { // object is a literal triple.object.type = 'literal'; if (object.type === RDF_PLAIN_LITERAL) { if (object.language) { triple.object.datatype = RDF_LANGSTRING; triple.object.language = object.language; } else { triple.object.datatype = XSD_STRING; } } else { triple.object.datatype = object.type; } } triple.object.value = value; // add triple to dataset in default graph dataset['@default'].push(triple); } }); }); return dataset; }
[ "function", "processGraph", "(", "data", ")", "{", "let", "dataset", "=", "{", "'@default'", ":", "[", "]", "}", ";", "let", "subjects", "=", "data", ".", "subjects", ",", "htmlMapper", "=", "n", "=>", "{", "let", "div", "=", "n", ".", "ownerDocument", ".", "createElement", "(", "'div'", ")", ";", "div", ".", "appendChild", "(", "n", ".", "cloneNode", "(", "true", ")", ")", ";", "return", "div", ".", "innerHTML", ";", "}", ";", "Object", ".", "keys", "(", "subjects", ")", ".", "forEach", "(", "subject", "=>", "{", "let", "predicates", "=", "subjects", "[", "subject", "]", ".", "predicates", ";", "Object", ".", "keys", "(", "predicates", ")", ".", "forEach", "(", "predicate", "=>", "{", "// iterate over objects", "let", "objects", "=", "predicates", "[", "predicate", "]", ".", "objects", ";", "for", "(", "let", "oi", "=", "0", ";", "oi", "<", "objects", ".", "length", ";", "++", "oi", ")", "{", "let", "object", "=", "objects", "[", "oi", "]", ";", "// create RDF triple", "let", "triple", "=", "{", "}", ";", "// add subject & predicate", "triple", ".", "subject", "=", "{", "type", ":", "subject", ".", "indexOf", "(", "'_:'", ")", "===", "0", "?", "'blank node'", ":", "'IRI'", ",", "value", ":", "subject", "}", ";", "triple", ".", "predicate", "=", "{", "type", ":", "predicate", ".", "indexOf", "(", "'_:'", ")", "===", "0", "?", "'blank node'", ":", "'IRI'", ",", "value", ":", "predicate", "}", ";", "triple", ".", "object", "=", "{", "}", ";", "// serialize XML literal", "let", "value", "=", "object", ".", "value", ";", "// !!! TODO: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!", "// The below actually most likely does NOT work.", "// In most usage contexts this will be an HTML DOM, passing it to xmldom's XMLSerializer", "// will cause it to call .toString() on all the nodes it finds — this only works inside", "// xmldom.", "if", "(", "object", ".", "type", "===", "RDF_XML_LITERAL", ")", "{", "// initialize XMLSerializer", "let", "serializer", "=", "new", "XMLSerializer", "(", ")", ";", "value", "=", "Array", ".", "from", "(", "object", ".", "value", ")", ".", "map", "(", "n", "=>", "serializer", ".", "serializeToString", "(", "n", ")", ")", ".", "join", "(", "''", ")", ";", "triple", ".", "object", ".", "datatype", "=", "RDF_XML_LITERAL", ";", "}", "// serialise HTML literal", "else", "if", "(", "object", ".", "type", "===", "RDF_HTML_LITERAL", ")", "{", "value", "=", "Array", ".", "from", "(", "object", ".", "value", ")", ".", "map", "(", "htmlMapper", ")", ".", "join", "(", "''", ")", ";", "triple", ".", "object", ".", "datatype", "=", "RDF_HTML_LITERAL", ";", "}", "// object is an IRI", "else", "if", "(", "object", ".", "type", "===", "RDF_OBJECT", ")", "{", "if", "(", "object", ".", "value", ".", "indexOf", "(", "'_:'", ")", "===", "0", ")", "triple", ".", "object", ".", "type", "=", "'blank node'", ";", "else", "triple", ".", "object", ".", "type", "=", "'IRI'", ";", "}", "else", "{", "// object is a literal", "triple", ".", "object", ".", "type", "=", "'literal'", ";", "if", "(", "object", ".", "type", "===", "RDF_PLAIN_LITERAL", ")", "{", "if", "(", "object", ".", "language", ")", "{", "triple", ".", "object", ".", "datatype", "=", "RDF_LANGSTRING", ";", "triple", ".", "object", ".", "language", "=", "object", ".", "language", ";", "}", "else", "{", "triple", ".", "object", ".", "datatype", "=", "XSD_STRING", ";", "}", "}", "else", "{", "triple", ".", "object", ".", "datatype", "=", "object", ".", "type", ";", "}", "}", "triple", ".", "object", ".", "value", "=", "value", ";", "// add triple to dataset in default graph", "dataset", "[", "'@default'", "]", ".", "push", "(", "triple", ")", ";", "}", "}", ")", ";", "}", ")", ";", "return", "dataset", ";", "}" ]
This function is mostly taken from the jsonld.js lib but updated to the latest green-turtle API, and for support for HTML
[ "This", "function", "is", "mostly", "taken", "from", "the", "jsonld", ".", "js", "lib", "but", "updated", "to", "the", "latest", "green", "-", "turtle", "API", "and", "for", "support", "for", "HTML" ]
694459fa3cce03832f9a67f522a5143c89a47b84
https://github.com/scienceai/jsonld-rdfa-parser/blob/694459fa3cce03832f9a67f522a5143c89a47b84/src/index.js#L64-L148
37,552
chriszarate/supergenpass-lib
src/lib/hash.js
customBase64Hash
function customBase64Hash(str, hashFunction) { const result = hashFunction(str).toString(encBase64); return customBase64(result); }
javascript
function customBase64Hash(str, hashFunction) { const result = hashFunction(str).toString(encBase64); return customBase64(result); }
[ "function", "customBase64Hash", "(", "str", ",", "hashFunction", ")", "{", "const", "result", "=", "hashFunction", "(", "str", ")", ".", "toString", "(", "encBase64", ")", ";", "return", "customBase64", "(", "result", ")", ";", "}" ]
Compute hexadecimal hash and convert it to Base-64.
[ "Compute", "hexadecimal", "hash", "and", "convert", "it", "to", "Base", "-", "64", "." ]
eb9ee92050813d498229bfe0e6ccbcb87124cf90
https://github.com/chriszarate/supergenpass-lib/blob/eb9ee92050813d498229bfe0e6ccbcb87124cf90/src/lib/hash.js#L19-L22
37,553
chriszarate/supergenpass-lib
src/lib/hash.js
hash
function hash(method) { // Is user supplies a function, use it and assume they will take of any // encoding (Base-64 or otherwise). if (typeof method === 'function') { return method; } if (hashFunctions.hasOwnProperty(method)) { return hashFunctions[method]; } throw new Error(`Could not resolve hash function, received ${typeof method}.`); }
javascript
function hash(method) { // Is user supplies a function, use it and assume they will take of any // encoding (Base-64 or otherwise). if (typeof method === 'function') { return method; } if (hashFunctions.hasOwnProperty(method)) { return hashFunctions[method]; } throw new Error(`Could not resolve hash function, received ${typeof method}.`); }
[ "function", "hash", "(", "method", ")", "{", "// Is user supplies a function, use it and assume they will take of any", "// encoding (Base-64 or otherwise).", "if", "(", "typeof", "method", "===", "'function'", ")", "{", "return", "method", ";", "}", "if", "(", "hashFunctions", ".", "hasOwnProperty", "(", "method", ")", ")", "{", "return", "hashFunctions", "[", "method", "]", ";", "}", "throw", "new", "Error", "(", "`", "${", "typeof", "method", "}", "`", ")", ";", "}" ]
Return a hash function for SGP to use.
[ "Return", "a", "hash", "function", "for", "SGP", "to", "use", "." ]
eb9ee92050813d498229bfe0e6ccbcb87124cf90
https://github.com/chriszarate/supergenpass-lib/blob/eb9ee92050813d498229bfe0e6ccbcb87124cf90/src/lib/hash.js#L30-L42
37,554
cowboy/node-toc
lib/toc.js
normalize
function normalize(options, templates) { // Options override defaults and toc methods. var result = _.defaults({}, options, toc, toc.defaults); // Remove "core" methods from result object. ['defaults', 'process', 'anchorize', 'toc'].forEach(function(prop) { delete result[prop]; }); // Compile Lodash string templates into functions. (templates || []).forEach(function(tmpl) { if (typeof result[tmpl] === 'string') { result[tmpl] = _.template(result[tmpl]); } }); return result; }
javascript
function normalize(options, templates) { // Options override defaults and toc methods. var result = _.defaults({}, options, toc, toc.defaults); // Remove "core" methods from result object. ['defaults', 'process', 'anchorize', 'toc'].forEach(function(prop) { delete result[prop]; }); // Compile Lodash string templates into functions. (templates || []).forEach(function(tmpl) { if (typeof result[tmpl] === 'string') { result[tmpl] = _.template(result[tmpl]); } }); return result; }
[ "function", "normalize", "(", "options", ",", "templates", ")", "{", "// Options override defaults and toc methods.", "var", "result", "=", "_", ".", "defaults", "(", "{", "}", ",", "options", ",", "toc", ",", "toc", ".", "defaults", ")", ";", "// Remove \"core\" methods from result object.", "[", "'defaults'", ",", "'process'", ",", "'anchorize'", ",", "'toc'", "]", ".", "forEach", "(", "function", "(", "prop", ")", "{", "delete", "result", "[", "prop", "]", ";", "}", ")", ";", "// Compile Lodash string templates into functions.", "(", "templates", "||", "[", "]", ")", ".", "forEach", "(", "function", "(", "tmpl", ")", "{", "if", "(", "typeof", "result", "[", "tmpl", "]", "===", "'string'", ")", "{", "result", "[", "tmpl", "]", "=", "_", ".", "template", "(", "result", "[", "tmpl", "]", ")", ";", "}", "}", ")", ";", "return", "result", ";", "}" ]
Compile specified lodash string template properties into functions.
[ "Compile", "specified", "lodash", "string", "template", "properties", "into", "functions", "." ]
a6907a18cafb6741d9770a93f27f0fda98a8cff3
https://github.com/cowboy/node-toc/blob/a6907a18cafb6741d9770a93f27f0fda98a8cff3/lib/toc.js#L82-L96
37,555
BohemiaInteractive/bi-service
lib/cli/runCmd.js
_parseShellConfigOptions
function _parseShellConfigOptions(argv) { var out = {}; //`parse-pos-args` value is `true` by default, it must be //explicitly set to falsy value thus undefined & null values does not count if (argv['parse-pos-args'] === false || argv['parse-pos-args'] === 0) { setConfigPathOption(out); return out; } var options = argv.options.reduce(function(out, option, index) { if (index % 2 === 0) { out.names.push(option); } else { out.values.push(option); } return out; }, { names: [], values: [] }); if (argv.options.length % 2 !== 0) { throw new Error( `Invalid number of shell positional arguments received. Possitional arguments are expected to be in "[key] [value]" pairs` ); } options.names.forEach(function(propPath, index) { _.set( out, propPath, json5.parse(options.values[index]) ); }); setConfigPathOption(out); return out; function setConfigPathOption(obj) { //for overwriting expected config filepath we can use --config option only if (argv.config) { obj.fileConfigPath = argv.config; obj.fileConfigPath = path.normalize(obj.fileConfigPath); } else { delete obj.fileConfigPath; } } }
javascript
function _parseShellConfigOptions(argv) { var out = {}; //`parse-pos-args` value is `true` by default, it must be //explicitly set to falsy value thus undefined & null values does not count if (argv['parse-pos-args'] === false || argv['parse-pos-args'] === 0) { setConfigPathOption(out); return out; } var options = argv.options.reduce(function(out, option, index) { if (index % 2 === 0) { out.names.push(option); } else { out.values.push(option); } return out; }, { names: [], values: [] }); if (argv.options.length % 2 !== 0) { throw new Error( `Invalid number of shell positional arguments received. Possitional arguments are expected to be in "[key] [value]" pairs` ); } options.names.forEach(function(propPath, index) { _.set( out, propPath, json5.parse(options.values[index]) ); }); setConfigPathOption(out); return out; function setConfigPathOption(obj) { //for overwriting expected config filepath we can use --config option only if (argv.config) { obj.fileConfigPath = argv.config; obj.fileConfigPath = path.normalize(obj.fileConfigPath); } else { delete obj.fileConfigPath; } } }
[ "function", "_parseShellConfigOptions", "(", "argv", ")", "{", "var", "out", "=", "{", "}", ";", "//`parse-pos-args` value is `true` by default, it must be", "//explicitly set to falsy value thus undefined & null values does not count", "if", "(", "argv", "[", "'parse-pos-args'", "]", "===", "false", "||", "argv", "[", "'parse-pos-args'", "]", "===", "0", ")", "{", "setConfigPathOption", "(", "out", ")", ";", "return", "out", ";", "}", "var", "options", "=", "argv", ".", "options", ".", "reduce", "(", "function", "(", "out", ",", "option", ",", "index", ")", "{", "if", "(", "index", "%", "2", "===", "0", ")", "{", "out", ".", "names", ".", "push", "(", "option", ")", ";", "}", "else", "{", "out", ".", "values", ".", "push", "(", "option", ")", ";", "}", "return", "out", ";", "}", ",", "{", "names", ":", "[", "]", ",", "values", ":", "[", "]", "}", ")", ";", "if", "(", "argv", ".", "options", ".", "length", "%", "2", "!==", "0", ")", "{", "throw", "new", "Error", "(", "`", "`", ")", ";", "}", "options", ".", "names", ".", "forEach", "(", "function", "(", "propPath", ",", "index", ")", "{", "_", ".", "set", "(", "out", ",", "propPath", ",", "json5", ".", "parse", "(", "options", ".", "values", "[", "index", "]", ")", ")", ";", "}", ")", ";", "setConfigPathOption", "(", "out", ")", ";", "return", "out", ";", "function", "setConfigPathOption", "(", "obj", ")", "{", "//for overwriting expected config filepath we can use --config option only", "if", "(", "argv", ".", "config", ")", "{", "obj", ".", "fileConfigPath", "=", "argv", ".", "config", ";", "obj", ".", "fileConfigPath", "=", "path", ".", "normalize", "(", "obj", ".", "fileConfigPath", ")", ";", "}", "else", "{", "delete", "obj", ".", "fileConfigPath", ";", "}", "}", "}" ]
returns parsed object with positional shell arguments. These options will then overwrite option values set in configuration file @private @param {Object} argv - shell arguments @return {Object}
[ "returns", "parsed", "object", "with", "positional", "shell", "arguments", ".", "These", "options", "will", "then", "overwrite", "option", "values", "set", "in", "configuration", "file" ]
89e76f2e93714a3150ce7f59f16f646e4bdbbce1
https://github.com/BohemiaInteractive/bi-service/blob/89e76f2e93714a3150ce7f59f16f646e4bdbbce1/lib/cli/runCmd.js#L132-L182
37,556
joshfire/woodman
lib/logevent.js
function (loggerName, level, message) { this.time = new Date(); this.loggerName = loggerName; this.level = level; this.message = message; }
javascript
function (loggerName, level, message) { this.time = new Date(); this.loggerName = loggerName; this.level = level; this.message = message; }
[ "function", "(", "loggerName", ",", "level", ",", "message", ")", "{", "this", ".", "time", "=", "new", "Date", "(", ")", ";", "this", ".", "loggerName", "=", "loggerName", ";", "this", ".", "level", "=", "level", ";", "this", ".", "message", "=", "message", ";", "}" ]
Definition of the LogEvent class. @constructor @param {string} loggerName Name of the logger that creates this event @param {string} level The trace level ('info', 'warning', 'error'...) @param {Message} message The message to log.
[ "Definition", "of", "the", "LogEvent", "class", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/lib/logevent.js#L29-L34
37,557
jimivdw/grunt-mutation-testing
lib/reporting/html/FileHtmlBuilder.js
writeReport
function writeReport(fileResult, formatter, formattedSourceLines, baseDir) { var fileName = fileResult.fileName, stats = StatUtils.decorateStatPercentages(fileResult.stats), parentDir = path.normalize(baseDir + '/..'), mutations = formatter.formatMutations(fileResult.mutationResults), breadcrumb = new IndexHtmlBuilder(baseDir).linkPathItems({ currentDir: parentDir, fileName: baseDir + '/' + fileName + '.html', separator: ' >> ', relativePath: getRelativeDistance(baseDir + '/' + fileName, baseDir ), linkDirectoryOnly: true }); var file = Templates.fileTemplate({ sourceLines: formattedSourceLines, mutations: mutations }); fs.writeFileSync( path.join(baseDir, fileName + ".html"), Templates.baseTemplate({ style: Templates.baseStyleTemplate({ additionalStyle: Templates.fileStyleCode }), script: Templates.baseScriptTemplate({ additionalScript: Templates.fileScriptCode }), fileName: path.basename(fileName), stats: stats, status: stats.successRate > this._config.successThreshold ? 'killed' : stats.all > 0 ? 'survived' : 'neutral', breadcrumb: breadcrumb, generatedAt: new Date().toLocaleString(), content: file }) ); }
javascript
function writeReport(fileResult, formatter, formattedSourceLines, baseDir) { var fileName = fileResult.fileName, stats = StatUtils.decorateStatPercentages(fileResult.stats), parentDir = path.normalize(baseDir + '/..'), mutations = formatter.formatMutations(fileResult.mutationResults), breadcrumb = new IndexHtmlBuilder(baseDir).linkPathItems({ currentDir: parentDir, fileName: baseDir + '/' + fileName + '.html', separator: ' >> ', relativePath: getRelativeDistance(baseDir + '/' + fileName, baseDir ), linkDirectoryOnly: true }); var file = Templates.fileTemplate({ sourceLines: formattedSourceLines, mutations: mutations }); fs.writeFileSync( path.join(baseDir, fileName + ".html"), Templates.baseTemplate({ style: Templates.baseStyleTemplate({ additionalStyle: Templates.fileStyleCode }), script: Templates.baseScriptTemplate({ additionalScript: Templates.fileScriptCode }), fileName: path.basename(fileName), stats: stats, status: stats.successRate > this._config.successThreshold ? 'killed' : stats.all > 0 ? 'survived' : 'neutral', breadcrumb: breadcrumb, generatedAt: new Date().toLocaleString(), content: file }) ); }
[ "function", "writeReport", "(", "fileResult", ",", "formatter", ",", "formattedSourceLines", ",", "baseDir", ")", "{", "var", "fileName", "=", "fileResult", ".", "fileName", ",", "stats", "=", "StatUtils", ".", "decorateStatPercentages", "(", "fileResult", ".", "stats", ")", ",", "parentDir", "=", "path", ".", "normalize", "(", "baseDir", "+", "'/..'", ")", ",", "mutations", "=", "formatter", ".", "formatMutations", "(", "fileResult", ".", "mutationResults", ")", ",", "breadcrumb", "=", "new", "IndexHtmlBuilder", "(", "baseDir", ")", ".", "linkPathItems", "(", "{", "currentDir", ":", "parentDir", ",", "fileName", ":", "baseDir", "+", "'/'", "+", "fileName", "+", "'.html'", ",", "separator", ":", "' >> '", ",", "relativePath", ":", "getRelativeDistance", "(", "baseDir", "+", "'/'", "+", "fileName", ",", "baseDir", ")", ",", "linkDirectoryOnly", ":", "true", "}", ")", ";", "var", "file", "=", "Templates", ".", "fileTemplate", "(", "{", "sourceLines", ":", "formattedSourceLines", ",", "mutations", ":", "mutations", "}", ")", ";", "fs", ".", "writeFileSync", "(", "path", ".", "join", "(", "baseDir", ",", "fileName", "+", "\".html\"", ")", ",", "Templates", ".", "baseTemplate", "(", "{", "style", ":", "Templates", ".", "baseStyleTemplate", "(", "{", "additionalStyle", ":", "Templates", ".", "fileStyleCode", "}", ")", ",", "script", ":", "Templates", ".", "baseScriptTemplate", "(", "{", "additionalScript", ":", "Templates", ".", "fileScriptCode", "}", ")", ",", "fileName", ":", "path", ".", "basename", "(", "fileName", ")", ",", "stats", ":", "stats", ",", "status", ":", "stats", ".", "successRate", ">", "this", ".", "_config", ".", "successThreshold", "?", "'killed'", ":", "stats", ".", "all", ">", "0", "?", "'survived'", ":", "'neutral'", ",", "breadcrumb", ":", "breadcrumb", ",", "generatedAt", ":", "new", "Date", "(", ")", ".", "toLocaleString", "(", ")", ",", "content", ":", "file", "}", ")", ")", ";", "}" ]
write the report to file
[ "write", "the", "report", "to", "file" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/reporting/html/FileHtmlBuilder.js#L52-L83
37,558
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(obj, keys, caseSensitive /* default: false */) { var key, keyLower, newObj = {}; if (!$.isArray(keys) || !keys.length) { return newObj; } for (var i = 0; i < keys.length; i++) { key = keys[i]; if (obj.hasOwnProperty(key)) { newObj[key] = obj[key]; } if(caseSensitive === true) { continue; } //when getting data-* attributes via $.data() it's converted to lowercase. //details: http://stackoverflow.com/questions/7602565/using-data-attributes-with-jquery //workaround is code below. keyLower = key.toLowerCase(); if (obj.hasOwnProperty(keyLower)) { newObj[key] = obj[keyLower]; } } return newObj; }
javascript
function(obj, keys, caseSensitive /* default: false */) { var key, keyLower, newObj = {}; if (!$.isArray(keys) || !keys.length) { return newObj; } for (var i = 0; i < keys.length; i++) { key = keys[i]; if (obj.hasOwnProperty(key)) { newObj[key] = obj[key]; } if(caseSensitive === true) { continue; } //when getting data-* attributes via $.data() it's converted to lowercase. //details: http://stackoverflow.com/questions/7602565/using-data-attributes-with-jquery //workaround is code below. keyLower = key.toLowerCase(); if (obj.hasOwnProperty(keyLower)) { newObj[key] = obj[keyLower]; } } return newObj; }
[ "function", "(", "obj", ",", "keys", ",", "caseSensitive", "/* default: false */", ")", "{", "var", "key", ",", "keyLower", ",", "newObj", "=", "{", "}", ";", "if", "(", "!", "$", ".", "isArray", "(", "keys", ")", "||", "!", "keys", ".", "length", ")", "{", "return", "newObj", ";", "}", "for", "(", "var", "i", "=", "0", ";", "i", "<", "keys", ".", "length", ";", "i", "++", ")", "{", "key", "=", "keys", "[", "i", "]", ";", "if", "(", "obj", ".", "hasOwnProperty", "(", "key", ")", ")", "{", "newObj", "[", "key", "]", "=", "obj", "[", "key", "]", ";", "}", "if", "(", "caseSensitive", "===", "true", ")", "{", "continue", ";", "}", "//when getting data-* attributes via $.data() it's converted to lowercase.", "//details: http://stackoverflow.com/questions/7602565/using-data-attributes-with-jquery", "//workaround is code below.", "keyLower", "=", "key", ".", "toLowerCase", "(", ")", ";", "if", "(", "obj", ".", "hasOwnProperty", "(", "keyLower", ")", ")", "{", "newObj", "[", "key", "]", "=", "obj", "[", "keyLower", "]", ";", "}", "}", "return", "newObj", ";", "}" ]
slice object by specified keys
[ "slice", "object", "by", "specified", "keys" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L688-L715
37,559
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(element, options) { this.$element = $(element); //since 1.4.1 container do not use data-* directly as they already merged into options. this.options = $.extend({}, $.fn.editableContainer.defaults, options); this.splitOptions(); //set scope of form callbacks to element this.formOptions.scope = this.$element[0]; this.initContainer(); //flag to hide container, when saving value will finish this.delayedHide = false; //bind 'destroyed' listener to destroy container when element is removed from dom this.$element.on('destroyed', $.proxy(function(){ this.destroy(); }, this)); //attach document handler to close containers on click / escape if(!$(document).data('editable-handlers-attached')) { //close all on escape $(document).on('keyup.editable', function (e) { if (e.which === 27) { $('.editable-open').editableContainer('hide'); //todo: return focus on element } }); //close containers when click outside //(mousedown could be better than click, it closes everything also on drag drop) $(document).on('click.editable', function(e) { var $target = $(e.target), i, exclude_classes = ['.editable-container', '.ui-datepicker-header', '.datepicker', //in inline mode datepicker is rendered into body '.modal-backdrop', '.bootstrap-wysihtml5-insert-image-modal', '.bootstrap-wysihtml5-insert-link-modal' ]; //check if element is detached. It occurs when clicking in bootstrap datepicker if (!$.contains(document.documentElement, e.target)) { return; } //for some reason FF 20 generates extra event (click) in select2 widget with e.target = document //we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199 //Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec if($target.is(document)) { return; } //if click inside one of exclude classes --> no nothing for(i=0; i<exclude_classes.length; i++) { if($target.is(exclude_classes[i]) || $target.parents(exclude_classes[i]).length) { return; } } //close all open containers (except one - target) Popup.prototype.closeOthers(e.target); }); $(document).data('editable-handlers-attached', true); } }
javascript
function(element, options) { this.$element = $(element); //since 1.4.1 container do not use data-* directly as they already merged into options. this.options = $.extend({}, $.fn.editableContainer.defaults, options); this.splitOptions(); //set scope of form callbacks to element this.formOptions.scope = this.$element[0]; this.initContainer(); //flag to hide container, when saving value will finish this.delayedHide = false; //bind 'destroyed' listener to destroy container when element is removed from dom this.$element.on('destroyed', $.proxy(function(){ this.destroy(); }, this)); //attach document handler to close containers on click / escape if(!$(document).data('editable-handlers-attached')) { //close all on escape $(document).on('keyup.editable', function (e) { if (e.which === 27) { $('.editable-open').editableContainer('hide'); //todo: return focus on element } }); //close containers when click outside //(mousedown could be better than click, it closes everything also on drag drop) $(document).on('click.editable', function(e) { var $target = $(e.target), i, exclude_classes = ['.editable-container', '.ui-datepicker-header', '.datepicker', //in inline mode datepicker is rendered into body '.modal-backdrop', '.bootstrap-wysihtml5-insert-image-modal', '.bootstrap-wysihtml5-insert-link-modal' ]; //check if element is detached. It occurs when clicking in bootstrap datepicker if (!$.contains(document.documentElement, e.target)) { return; } //for some reason FF 20 generates extra event (click) in select2 widget with e.target = document //we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199 //Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec if($target.is(document)) { return; } //if click inside one of exclude classes --> no nothing for(i=0; i<exclude_classes.length; i++) { if($target.is(exclude_classes[i]) || $target.parents(exclude_classes[i]).length) { return; } } //close all open containers (except one - target) Popup.prototype.closeOthers(e.target); }); $(document).data('editable-handlers-attached', true); } }
[ "function", "(", "element", ",", "options", ")", "{", "this", ".", "$element", "=", "$", "(", "element", ")", ";", "//since 1.4.1 container do not use data-* directly as they already merged into options.", "this", ".", "options", "=", "$", ".", "extend", "(", "{", "}", ",", "$", ".", "fn", ".", "editableContainer", ".", "defaults", ",", "options", ")", ";", "this", ".", "splitOptions", "(", ")", ";", "//set scope of form callbacks to element", "this", ".", "formOptions", ".", "scope", "=", "this", ".", "$element", "[", "0", "]", ";", "this", ".", "initContainer", "(", ")", ";", "//flag to hide container, when saving value will finish", "this", ".", "delayedHide", "=", "false", ";", "//bind 'destroyed' listener to destroy container when element is removed from dom", "this", ".", "$element", ".", "on", "(", "'destroyed'", ",", "$", ".", "proxy", "(", "function", "(", ")", "{", "this", ".", "destroy", "(", ")", ";", "}", ",", "this", ")", ")", ";", "//attach document handler to close containers on click / escape", "if", "(", "!", "$", "(", "document", ")", ".", "data", "(", "'editable-handlers-attached'", ")", ")", "{", "//close all on escape", "$", "(", "document", ")", ".", "on", "(", "'keyup.editable'", ",", "function", "(", "e", ")", "{", "if", "(", "e", ".", "which", "===", "27", ")", "{", "$", "(", "'.editable-open'", ")", ".", "editableContainer", "(", "'hide'", ")", ";", "//todo: return focus on element ", "}", "}", ")", ";", "//close containers when click outside ", "//(mousedown could be better than click, it closes everything also on drag drop)", "$", "(", "document", ")", ".", "on", "(", "'click.editable'", ",", "function", "(", "e", ")", "{", "var", "$target", "=", "$", "(", "e", ".", "target", ")", ",", "i", ",", "exclude_classes", "=", "[", "'.editable-container'", ",", "'.ui-datepicker-header'", ",", "'.datepicker'", ",", "//in inline mode datepicker is rendered into body", "'.modal-backdrop'", ",", "'.bootstrap-wysihtml5-insert-image-modal'", ",", "'.bootstrap-wysihtml5-insert-link-modal'", "]", ";", "//check if element is detached. It occurs when clicking in bootstrap datepicker", "if", "(", "!", "$", ".", "contains", "(", "document", ".", "documentElement", ",", "e", ".", "target", ")", ")", "{", "return", ";", "}", "//for some reason FF 20 generates extra event (click) in select2 widget with e.target = document", "//we need to filter it via construction below. See https://github.com/vitalets/x-editable/issues/199", "//Possibly related to http://stackoverflow.com/questions/10119793/why-does-firefox-react-differently-from-webkit-and-ie-to-click-event-on-selec", "if", "(", "$target", ".", "is", "(", "document", ")", ")", "{", "return", ";", "}", "//if click inside one of exclude classes --> no nothing", "for", "(", "i", "=", "0", ";", "i", "<", "exclude_classes", ".", "length", ";", "i", "++", ")", "{", "if", "(", "$target", ".", "is", "(", "exclude_classes", "[", "i", "]", ")", "||", "$target", ".", "parents", "(", "exclude_classes", "[", "i", "]", ")", ".", "length", ")", "{", "return", ";", "}", "}", "//close all open containers (except one - target)", "Popup", ".", "prototype", ".", "closeOthers", "(", "e", ".", "target", ")", ";", "}", ")", ";", "$", "(", "document", ")", ".", "data", "(", "'editable-handlers-attached'", ",", "true", ")", ";", "}", "}" ]
css class applied to container element
[ "css", "class", "applied", "to", "container", "element" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L901-L967
37,560
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function() { this.containerOptions = {}; this.formOptions = {}; if(!$.fn[this.containerName]) { throw new Error(this.containerName + ' not found. Have you included corresponding js file?'); } var cDef = $.fn[this.containerName].defaults; //keys defined in container defaults go to container, others go to form for(var k in this.options) { if(k in cDef) { this.containerOptions[k] = this.options[k]; } else { this.formOptions[k] = this.options[k]; } } }
javascript
function() { this.containerOptions = {}; this.formOptions = {}; if(!$.fn[this.containerName]) { throw new Error(this.containerName + ' not found. Have you included corresponding js file?'); } var cDef = $.fn[this.containerName].defaults; //keys defined in container defaults go to container, others go to form for(var k in this.options) { if(k in cDef) { this.containerOptions[k] = this.options[k]; } else { this.formOptions[k] = this.options[k]; } } }
[ "function", "(", ")", "{", "this", ".", "containerOptions", "=", "{", "}", ";", "this", ".", "formOptions", "=", "{", "}", ";", "if", "(", "!", "$", ".", "fn", "[", "this", ".", "containerName", "]", ")", "{", "throw", "new", "Error", "(", "this", ".", "containerName", "+", "' not found. Have you included corresponding js file?'", ")", ";", "}", "var", "cDef", "=", "$", ".", "fn", "[", "this", ".", "containerName", "]", ".", "defaults", ";", "//keys defined in container defaults go to container, others go to form", "for", "(", "var", "k", "in", "this", ".", "options", ")", "{", "if", "(", "k", "in", "cDef", ")", "{", "this", ".", "containerOptions", "[", "k", "]", "=", "this", ".", "options", "[", "k", "]", ";", "}", "else", "{", "this", ".", "formOptions", "[", "k", "]", "=", "this", ".", "options", "[", "k", "]", ";", "}", "}", "}" ]
split options on containerOptions and formOptions
[ "split", "options", "on", "containerOptions", "and", "formOptions" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L970-L987
37,561
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(reason) { if(!this.tip() || !this.tip().is(':visible') || !this.$element.hasClass('editable-open')) { return; } //if form is saving value, schedule hide if(this.$form.data('editableform').isSaving) { this.delayedHide = {reason: reason}; return; } else { this.delayedHide = false; } this.$element.removeClass('editable-open'); this.innerHide(); /** Fired when container was hidden. It occurs on both save or cancel. **Note:** Bootstrap popover has own `hidden` event that now cannot be separated from x-editable's one. The workaround is to check `arguments.length` that is always `2` for x-editable. @event hidden @param {object} event event object @param {string} reason Reason caused hiding. Can be <code>save|cancel|onblur|nochange|manual</code> @example $('#username').on('hidden', function(e, reason) { if(reason === 'save' || reason === 'cancel') { //auto-open next editable $(this).closest('tr').next().find('.editable').editable('show'); } }); **/ this.$element.triggerHandler('hidden', reason || 'manual'); }
javascript
function(reason) { if(!this.tip() || !this.tip().is(':visible') || !this.$element.hasClass('editable-open')) { return; } //if form is saving value, schedule hide if(this.$form.data('editableform').isSaving) { this.delayedHide = {reason: reason}; return; } else { this.delayedHide = false; } this.$element.removeClass('editable-open'); this.innerHide(); /** Fired when container was hidden. It occurs on both save or cancel. **Note:** Bootstrap popover has own `hidden` event that now cannot be separated from x-editable's one. The workaround is to check `arguments.length` that is always `2` for x-editable. @event hidden @param {object} event event object @param {string} reason Reason caused hiding. Can be <code>save|cancel|onblur|nochange|manual</code> @example $('#username').on('hidden', function(e, reason) { if(reason === 'save' || reason === 'cancel') { //auto-open next editable $(this).closest('tr').next().find('.editable').editable('show'); } }); **/ this.$element.triggerHandler('hidden', reason || 'manual'); }
[ "function", "(", "reason", ")", "{", "if", "(", "!", "this", ".", "tip", "(", ")", "||", "!", "this", ".", "tip", "(", ")", ".", "is", "(", "':visible'", ")", "||", "!", "this", ".", "$element", ".", "hasClass", "(", "'editable-open'", ")", ")", "{", "return", ";", "}", "//if form is saving value, schedule hide", "if", "(", "this", ".", "$form", ".", "data", "(", "'editableform'", ")", ".", "isSaving", ")", "{", "this", ".", "delayedHide", "=", "{", "reason", ":", "reason", "}", ";", "return", ";", "}", "else", "{", "this", ".", "delayedHide", "=", "false", ";", "}", "this", ".", "$element", ".", "removeClass", "(", "'editable-open'", ")", ";", "this", ".", "innerHide", "(", ")", ";", "/**\n Fired when container was hidden. It occurs on both save or cancel. \n **Note:** Bootstrap popover has own `hidden` event that now cannot be separated from x-editable's one.\n The workaround is to check `arguments.length` that is always `2` for x-editable. \n\n @event hidden \n @param {object} event event object\n @param {string} reason Reason caused hiding. Can be <code>save|cancel|onblur|nochange|manual</code>\n @example\n $('#username').on('hidden', function(e, reason) {\n if(reason === 'save' || reason === 'cancel') {\n //auto-open next editable\n $(this).closest('tr').next().find('.editable').editable('show');\n } \n });\n **/", "this", ".", "$element", ".", "triggerHandler", "(", "'hidden'", ",", "reason", "||", "'manual'", ")", ";", "}" ]
Hides container with form @method hide() @param {string} reason Reason caused hiding. Can be <code>save|cancel|onblur|nochange|undefined (=manual)</code>
[ "Hides", "container", "with", "form" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L1110-L1143
37,562
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(value, convertStr, response) { if(convertStr) { this.value = this.input.str2value(value); } else { this.value = value; } if(this.container) { this.container.option('value', this.value); } $.when(this.render(response)) .then($.proxy(function() { this.handleEmpty(); }, this)); }
javascript
function(value, convertStr, response) { if(convertStr) { this.value = this.input.str2value(value); } else { this.value = value; } if(this.container) { this.container.option('value', this.value); } $.when(this.render(response)) .then($.proxy(function() { this.handleEmpty(); }, this)); }
[ "function", "(", "value", ",", "convertStr", ",", "response", ")", "{", "if", "(", "convertStr", ")", "{", "this", ".", "value", "=", "this", ".", "input", ".", "str2value", "(", "value", ")", ";", "}", "else", "{", "this", ".", "value", "=", "value", ";", "}", "if", "(", "this", ".", "container", ")", "{", "this", ".", "container", ".", "option", "(", "'value'", ",", "this", ".", "value", ")", ";", "}", "$", ".", "when", "(", "this", ".", "render", "(", "response", ")", ")", ".", "then", "(", "$", ".", "proxy", "(", "function", "(", ")", "{", "this", ".", "handleEmpty", "(", ")", ";", "}", ",", "this", ")", ")", ";", "}" ]
Sets new value of editable @method setValue(value, convertStr) @param {mixed} value new value @param {boolean} convertStr whether to convert value from string to internal format
[ "Sets", "new", "value", "of", "editable" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L1887-L1900
37,563
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function() { if (this.options.clear) { this.$clear = $('<span class="editable-clear-x"></span>'); this.$input.after(this.$clear) .css('padding-right', 24) .keyup($.proxy(function(e) { //arrows, enter, tab, etc if(~$.inArray(e.keyCode, [40,38,9,13,27])) { return; } clearTimeout(this.t); var that = this; this.t = setTimeout(function() { that.toggleClear(e); }, 100); }, this)) .parent().css('position', 'relative'); this.$clear.click($.proxy(this.clear, this)); } }
javascript
function() { if (this.options.clear) { this.$clear = $('<span class="editable-clear-x"></span>'); this.$input.after(this.$clear) .css('padding-right', 24) .keyup($.proxy(function(e) { //arrows, enter, tab, etc if(~$.inArray(e.keyCode, [40,38,9,13,27])) { return; } clearTimeout(this.t); var that = this; this.t = setTimeout(function() { that.toggleClear(e); }, 100); }, this)) .parent().css('position', 'relative'); this.$clear.click($.proxy(this.clear, this)); } }
[ "function", "(", ")", "{", "if", "(", "this", ".", "options", ".", "clear", ")", "{", "this", ".", "$clear", "=", "$", "(", "'<span class=\"editable-clear-x\"></span>'", ")", ";", "this", ".", "$input", ".", "after", "(", "this", ".", "$clear", ")", ".", "css", "(", "'padding-right'", ",", "24", ")", ".", "keyup", "(", "$", ".", "proxy", "(", "function", "(", "e", ")", "{", "//arrows, enter, tab, etc", "if", "(", "~", "$", ".", "inArray", "(", "e", ".", "keyCode", ",", "[", "40", ",", "38", ",", "9", ",", "13", ",", "27", "]", ")", ")", "{", "return", ";", "}", "clearTimeout", "(", "this", ".", "t", ")", ";", "var", "that", "=", "this", ";", "this", ".", "t", "=", "setTimeout", "(", "function", "(", ")", "{", "that", ".", "toggleClear", "(", "e", ")", ";", "}", ",", "100", ")", ";", "}", ",", "this", ")", ")", ".", "parent", "(", ")", ".", "css", "(", "'position'", ",", "'relative'", ")", ";", "this", ".", "$clear", ".", "click", "(", "$", ".", "proxy", "(", "this", ".", "clear", ",", "this", ")", ")", ";", "}", "}" ]
render clear button
[ "render", "clear", "button" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L2831-L2853
37,564
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(str) { var reg, value = null; if(typeof str === 'string' && str.length) { reg = new RegExp('\\s*'+$.trim(this.options.separator)+'\\s*'); value = str.split(reg); } else if($.isArray(str)) { value = str; } else { value = [str]; } return value; }
javascript
function(str) { var reg, value = null; if(typeof str === 'string' && str.length) { reg = new RegExp('\\s*'+$.trim(this.options.separator)+'\\s*'); value = str.split(reg); } else if($.isArray(str)) { value = str; } else { value = [str]; } return value; }
[ "function", "(", "str", ")", "{", "var", "reg", ",", "value", "=", "null", ";", "if", "(", "typeof", "str", "===", "'string'", "&&", "str", ".", "length", ")", "{", "reg", "=", "new", "RegExp", "(", "'\\\\s*'", "+", "$", ".", "trim", "(", "this", ".", "options", ".", "separator", ")", "+", "'\\\\s*'", ")", ";", "value", "=", "str", ".", "split", "(", "reg", ")", ";", "}", "else", "if", "(", "$", ".", "isArray", "(", "str", ")", ")", "{", "value", "=", "str", ";", "}", "else", "{", "value", "=", "[", "str", "]", ";", "}", "return", "value", ";", "}" ]
parse separated string
[ "parse", "separated", "string" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L3190-L3201
37,565
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(value) { this.$input.prop('checked', false); if($.isArray(value) && value.length) { this.$input.each(function(i, el) { var $el = $(el); // cannot use $.inArray as it performs strict comparison $.each(value, function(j, val){ /*jslint eqeq: true*/ if($el.val() == val) { /*jslint eqeq: false*/ $el.prop('checked', true); } }); }); } }
javascript
function(value) { this.$input.prop('checked', false); if($.isArray(value) && value.length) { this.$input.each(function(i, el) { var $el = $(el); // cannot use $.inArray as it performs strict comparison $.each(value, function(j, val){ /*jslint eqeq: true*/ if($el.val() == val) { /*jslint eqeq: false*/ $el.prop('checked', true); } }); }); } }
[ "function", "(", "value", ")", "{", "this", ".", "$input", ".", "prop", "(", "'checked'", ",", "false", ")", ";", "if", "(", "$", ".", "isArray", "(", "value", ")", "&&", "value", ".", "length", ")", "{", "this", ".", "$input", ".", "each", "(", "function", "(", "i", ",", "el", ")", "{", "var", "$el", "=", "$", "(", "el", ")", ";", "// cannot use $.inArray as it performs strict comparison", "$", ".", "each", "(", "value", ",", "function", "(", "j", ",", "val", ")", "{", "/*jslint eqeq: true*/", "if", "(", "$el", ".", "val", "(", ")", "==", "val", ")", "{", "/*jslint eqeq: false*/", "$el", ".", "prop", "(", "'checked'", ",", "true", ")", ";", "}", "}", ")", ";", "}", ")", ";", "}", "}" ]
set checked on required checkboxes
[ "set", "checked", "on", "required", "checkboxes" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L3204-L3219
37,566
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js
function(value, element) { var html = [], checked = $.fn.editableutils.itemsByValue(value, this.sourceData); if(checked.length) { $.each(checked, function(i, v) { html.push($.fn.editableutils.escape(v.text)); }); $(element).html(html.join('<br>')); } else { $(element).empty(); } }
javascript
function(value, element) { var html = [], checked = $.fn.editableutils.itemsByValue(value, this.sourceData); if(checked.length) { $.each(checked, function(i, v) { html.push($.fn.editableutils.escape(v.text)); }); $(element).html(html.join('<br>')); } else { $(element).empty(); } }
[ "function", "(", "value", ",", "element", ")", "{", "var", "html", "=", "[", "]", ",", "checked", "=", "$", ".", "fn", ".", "editableutils", ".", "itemsByValue", "(", "value", ",", "this", ".", "sourceData", ")", ";", "if", "(", "checked", ".", "length", ")", "{", "$", ".", "each", "(", "checked", ",", "function", "(", "i", ",", "v", ")", "{", "html", ".", "push", "(", "$", ".", "fn", ".", "editableutils", ".", "escape", "(", "v", ".", "text", ")", ")", ";", "}", ")", ";", "$", "(", "element", ")", ".", "html", "(", "html", ".", "join", "(", "'<br>'", ")", ")", ";", "}", "else", "{", "$", "(", "element", ")", ".", "empty", "(", ")", ";", "}", "}" ]
collect text of checked boxes
[ "collect", "text", "of", "checked", "boxes" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/x-editable/bootstrap-editable.js#L3230-L3240
37,567
infrabel/themes-gnap
raw/ace/mustache/app/views/assets/scripts/calendar.js
function(date, allDay) { // this function is called when something is dropped // retrieve the dropped element's stored Event Object var originalEventObject = $(this).data('eventObject'); var $extraEventClass = $(this).attr('data-class'); // we need to copy it, so that multiple events don't have a reference to the same object var copiedEventObject = $.extend({}, originalEventObject); // assign it the date that was reported copiedEventObject.start = date; copiedEventObject.allDay = allDay; if($extraEventClass) copiedEventObject['className'] = [$extraEventClass]; // render the event on the calendar // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); // is the "remove after drop" checkbox checked? if ($('#drop-remove').is(':checked')) { // if so, remove the element from the "Draggable Events" list $(this).remove(); } }
javascript
function(date, allDay) { // this function is called when something is dropped // retrieve the dropped element's stored Event Object var originalEventObject = $(this).data('eventObject'); var $extraEventClass = $(this).attr('data-class'); // we need to copy it, so that multiple events don't have a reference to the same object var copiedEventObject = $.extend({}, originalEventObject); // assign it the date that was reported copiedEventObject.start = date; copiedEventObject.allDay = allDay; if($extraEventClass) copiedEventObject['className'] = [$extraEventClass]; // render the event on the calendar // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/) $('#calendar').fullCalendar('renderEvent', copiedEventObject, true); // is the "remove after drop" checkbox checked? if ($('#drop-remove').is(':checked')) { // if so, remove the element from the "Draggable Events" list $(this).remove(); } }
[ "function", "(", "date", ",", "allDay", ")", "{", "// this function is called when something is dropped", "// retrieve the dropped element's stored Event Object", "var", "originalEventObject", "=", "$", "(", "this", ")", ".", "data", "(", "'eventObject'", ")", ";", "var", "$extraEventClass", "=", "$", "(", "this", ")", ".", "attr", "(", "'data-class'", ")", ";", "// we need to copy it, so that multiple events don't have a reference to the same object", "var", "copiedEventObject", "=", "$", ".", "extend", "(", "{", "}", ",", "originalEventObject", ")", ";", "// assign it the date that was reported", "copiedEventObject", ".", "start", "=", "date", ";", "copiedEventObject", ".", "allDay", "=", "allDay", ";", "if", "(", "$extraEventClass", ")", "copiedEventObject", "[", "'className'", "]", "=", "[", "$extraEventClass", "]", ";", "// render the event on the calendar", "// the last `true` argument determines if the event \"sticks\" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)", "$", "(", "'#calendar'", ")", ".", "fullCalendar", "(", "'renderEvent'", ",", "copiedEventObject", ",", "true", ")", ";", "// is the \"remove after drop\" checkbox checked?", "if", "(", "$", "(", "'#drop-remove'", ")", ".", "is", "(", "':checked'", ")", ")", "{", "// if so, remove the element from the \"Draggable Events\" list", "$", "(", "this", ")", ".", "remove", "(", ")", ";", "}", "}" ]
this allows things to be dropped onto the calendar !!!
[ "this", "allows", "things", "to", "be", "dropped", "onto", "the", "calendar", "!!!" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/mustache/app/views/assets/scripts/calendar.js#L69-L94
37,568
BohemiaInteractive/bi-service
lib/common/route.js
applyCatchList
function applyCatchList(promise, req, res, catchList, index) { index = index || 0; if ( !Array.isArray(catchList) || index > catchList.length - 1 || !Array.isArray(catchList[index]) || !(catchList[index][1] instanceof Function) ) { return promise; } var args = _.clone(catchList[index]); var cb = args[1]; args[1] = function(err) { return cb(err, req, res); }; promise = promise.catch.apply(promise, args); return applyCatchList(promise, req, res, catchList, ++index); }
javascript
function applyCatchList(promise, req, res, catchList, index) { index = index || 0; if ( !Array.isArray(catchList) || index > catchList.length - 1 || !Array.isArray(catchList[index]) || !(catchList[index][1] instanceof Function) ) { return promise; } var args = _.clone(catchList[index]); var cb = args[1]; args[1] = function(err) { return cb(err, req, res); }; promise = promise.catch.apply(promise, args); return applyCatchList(promise, req, res, catchList, ++index); }
[ "function", "applyCatchList", "(", "promise", ",", "req", ",", "res", ",", "catchList", ",", "index", ")", "{", "index", "=", "index", "||", "0", ";", "if", "(", "!", "Array", ".", "isArray", "(", "catchList", ")", "||", "index", ">", "catchList", ".", "length", "-", "1", "||", "!", "Array", ".", "isArray", "(", "catchList", "[", "index", "]", ")", "||", "!", "(", "catchList", "[", "index", "]", "[", "1", "]", "instanceof", "Function", ")", ")", "{", "return", "promise", ";", "}", "var", "args", "=", "_", ".", "clone", "(", "catchList", "[", "index", "]", ")", ";", "var", "cb", "=", "args", "[", "1", "]", ";", "args", "[", "1", "]", "=", "function", "(", "err", ")", "{", "return", "cb", "(", "err", ",", "req", ",", "res", ")", ";", "}", ";", "promise", "=", "promise", ".", "catch", ".", "apply", "(", "promise", ",", "args", ")", ";", "return", "applyCatchList", "(", "promise", ",", "req", ",", "res", ",", "catchList", ",", "++", "index", ")", ";", "}" ]
applies collection of catch handler functions to provided Promise object @private @param {Promise} promise - the promise catch functions are going to be applied to @param {Object} req @param {Object} res @param {Array} catchList - array of arrays - each item of array is a pair of [ErrorFilterConstructor,FunctionErrHandler] @return {Promise}
[ "applies", "collection", "of", "catch", "handler", "functions", "to", "provided", "Promise", "object" ]
89e76f2e93714a3150ce7f59f16f646e4bdbbce1
https://github.com/BohemiaInteractive/bi-service/blob/89e76f2e93714a3150ce7f59f16f646e4bdbbce1/lib/common/route.js#L604-L624
37,569
adaptive-learning/flocs-visual-components
src/selectors/gameState.js
performMove
function performMove(fields, direction) { const oldSpaceshipPosition = findSpaceshipPosition(fields); const dx = { left: -1, ahead: 0, right: 1 }[direction]; const newSpaceshipPosition = [oldSpaceshipPosition[0] - 1, oldSpaceshipPosition[1] + dx]; const newFields = fields.map((row, i) => row.map((field, j) => { const [background, oldObjects] = field; let newObjects = oldObjects; if (i === oldSpaceshipPosition[0] && j === oldSpaceshipPosition[1]) { if (outsideWorld(fields, newSpaceshipPosition)) { let border = null; if (i === 0) { border = 'top'; } else if (j === 0) { border = 'left'; } else { border = 'right'; } newObjects = [`spaceship-out-${border}`]; } else { newObjects = removeSpaceship(oldObjects); } } if (i === newSpaceshipPosition[0] && j === newSpaceshipPosition[1]) { if (onRock(fields, newSpaceshipPosition)) { newObjects = [...newObjects, 'spaceship-broken']; } else { newObjects = [...newObjects, 'S']; } } return [background, newObjects]; })); return newFields; }
javascript
function performMove(fields, direction) { const oldSpaceshipPosition = findSpaceshipPosition(fields); const dx = { left: -1, ahead: 0, right: 1 }[direction]; const newSpaceshipPosition = [oldSpaceshipPosition[0] - 1, oldSpaceshipPosition[1] + dx]; const newFields = fields.map((row, i) => row.map((field, j) => { const [background, oldObjects] = field; let newObjects = oldObjects; if (i === oldSpaceshipPosition[0] && j === oldSpaceshipPosition[1]) { if (outsideWorld(fields, newSpaceshipPosition)) { let border = null; if (i === 0) { border = 'top'; } else if (j === 0) { border = 'left'; } else { border = 'right'; } newObjects = [`spaceship-out-${border}`]; } else { newObjects = removeSpaceship(oldObjects); } } if (i === newSpaceshipPosition[0] && j === newSpaceshipPosition[1]) { if (onRock(fields, newSpaceshipPosition)) { newObjects = [...newObjects, 'spaceship-broken']; } else { newObjects = [...newObjects, 'S']; } } return [background, newObjects]; })); return newFields; }
[ "function", "performMove", "(", "fields", ",", "direction", ")", "{", "const", "oldSpaceshipPosition", "=", "findSpaceshipPosition", "(", "fields", ")", ";", "const", "dx", "=", "{", "left", ":", "-", "1", ",", "ahead", ":", "0", ",", "right", ":", "1", "}", "[", "direction", "]", ";", "const", "newSpaceshipPosition", "=", "[", "oldSpaceshipPosition", "[", "0", "]", "-", "1", ",", "oldSpaceshipPosition", "[", "1", "]", "+", "dx", "]", ";", "const", "newFields", "=", "fields", ".", "map", "(", "(", "row", ",", "i", ")", "=>", "row", ".", "map", "(", "(", "field", ",", "j", ")", "=>", "{", "const", "[", "background", ",", "oldObjects", "]", "=", "field", ";", "let", "newObjects", "=", "oldObjects", ";", "if", "(", "i", "===", "oldSpaceshipPosition", "[", "0", "]", "&&", "j", "===", "oldSpaceshipPosition", "[", "1", "]", ")", "{", "if", "(", "outsideWorld", "(", "fields", ",", "newSpaceshipPosition", ")", ")", "{", "let", "border", "=", "null", ";", "if", "(", "i", "===", "0", ")", "{", "border", "=", "'top'", ";", "}", "else", "if", "(", "j", "===", "0", ")", "{", "border", "=", "'left'", ";", "}", "else", "{", "border", "=", "'right'", ";", "}", "newObjects", "=", "[", "`", "${", "border", "}", "`", "]", ";", "}", "else", "{", "newObjects", "=", "removeSpaceship", "(", "oldObjects", ")", ";", "}", "}", "if", "(", "i", "===", "newSpaceshipPosition", "[", "0", "]", "&&", "j", "===", "newSpaceshipPosition", "[", "1", "]", ")", "{", "if", "(", "onRock", "(", "fields", ",", "newSpaceshipPosition", ")", ")", "{", "newObjects", "=", "[", "...", "newObjects", ",", "'spaceship-broken'", "]", ";", "}", "else", "{", "newObjects", "=", "[", "...", "newObjects", ",", "'S'", "]", ";", "}", "}", "return", "[", "background", ",", "newObjects", "]", ";", "}", ")", ")", ";", "return", "newFields", ";", "}" ]
Return new 2D fields after move of the spaceship represented as object 'S'. Dicection is one of 'left', 'ahead', 'right'.
[ "Return", "new", "2D", "fields", "after", "move", "of", "the", "spaceship", "represented", "as", "object", "S", ".", "Dicection", "is", "one", "of", "left", "ahead", "right", "." ]
c62e80a1fd5ad65ae2cbe37a1d9450a96c3a9306
https://github.com/adaptive-learning/flocs-visual-components/blob/c62e80a1fd5ad65ae2cbe37a1d9450a96c3a9306/src/selectors/gameState.js#L280-L312
37,570
jimivdw/grunt-mutation-testing
lib/karma/KarmaServerPool.js
KarmaServerPool
function KarmaServerPool(config) { this._config = _.merge({ port: 12111, maxActiveServers: 5, startInterval: 100 }, config); this._instances = []; }
javascript
function KarmaServerPool(config) { this._config = _.merge({ port: 12111, maxActiveServers: 5, startInterval: 100 }, config); this._instances = []; }
[ "function", "KarmaServerPool", "(", "config", ")", "{", "this", ".", "_config", "=", "_", ".", "merge", "(", "{", "port", ":", "12111", ",", "maxActiveServers", ":", "5", ",", "startInterval", ":", "100", "}", ",", "config", ")", ";", "this", ".", "_instances", "=", "[", "]", ";", "}" ]
Constructor for a Karma server manager @param config {object} Configuration object for the server. @constructor
[ "Constructor", "for", "a", "Karma", "server", "manager" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/karma/KarmaServerPool.js#L25-L28
37,571
joshfire/woodman
lib/loggercontext.js
LoggerContext
function LoggerContext() { LifeCycle.call(this); /** * Context start time */ this.startTime = new Date(); /** * The list of trace levels that the logger context knows about */ this.logLevel = new LogLevel(); /** * Root logger, final ancestor of all loggers */ this.rootLogger = new Logger('[root]', this); /** * List of loggers that have been created, indexed by name. */ this.loggers = {}; /** * List of appenders that have been registered through a call to * "registerAppender", indexed by name. */ this.appenders = {}; /** * List of filters that have been registered through a call to * "registerFilter", indexed by name. */ this.filters = {}; /** * List of layouts that have been registered through a call to * "registerLayout", indexed by name. */ this.layouts = {}; /** * List of appenders that have been instantiated. * * The list is constructed when the configuration is applied. It is used * to start/stop appenders when corresponding functions are called on this * context. */ this.createdAppenders = []; /** * The context-wide filter. * * The filter is constructed when the configuration is applied. If the * configuration specifies more than one context-wide filter, a * CompositeFilter filter is created. */ this.filter = null; /** * Flag set when the context is up and running */ this.started = false; /** * Log events received by the context before it got a chance to start and * that need to be processed as soon as the context is operational * * The context keeps a maximum of 1000 events in memory. If more events are * received before the context becomes operational, the context starts to * drop events, replacing the first event with a warning that events had to * be droppes. That warning is sent to the root logger. */ this.pendingEvents = []; /** * Maximum number of log events that can be stored in the pending list. * * TODO: adjust this setting based on configuration settings. */ this.maxPendingEvents = 1000; /** * Number of log events that had to be discarded so far */ this.discardedPendingEvents = 0; }
javascript
function LoggerContext() { LifeCycle.call(this); /** * Context start time */ this.startTime = new Date(); /** * The list of trace levels that the logger context knows about */ this.logLevel = new LogLevel(); /** * Root logger, final ancestor of all loggers */ this.rootLogger = new Logger('[root]', this); /** * List of loggers that have been created, indexed by name. */ this.loggers = {}; /** * List of appenders that have been registered through a call to * "registerAppender", indexed by name. */ this.appenders = {}; /** * List of filters that have been registered through a call to * "registerFilter", indexed by name. */ this.filters = {}; /** * List of layouts that have been registered through a call to * "registerLayout", indexed by name. */ this.layouts = {}; /** * List of appenders that have been instantiated. * * The list is constructed when the configuration is applied. It is used * to start/stop appenders when corresponding functions are called on this * context. */ this.createdAppenders = []; /** * The context-wide filter. * * The filter is constructed when the configuration is applied. If the * configuration specifies more than one context-wide filter, a * CompositeFilter filter is created. */ this.filter = null; /** * Flag set when the context is up and running */ this.started = false; /** * Log events received by the context before it got a chance to start and * that need to be processed as soon as the context is operational * * The context keeps a maximum of 1000 events in memory. If more events are * received before the context becomes operational, the context starts to * drop events, replacing the first event with a warning that events had to * be droppes. That warning is sent to the root logger. */ this.pendingEvents = []; /** * Maximum number of log events that can be stored in the pending list. * * TODO: adjust this setting based on configuration settings. */ this.maxPendingEvents = 1000; /** * Number of log events that had to be discarded so far */ this.discardedPendingEvents = 0; }
[ "function", "LoggerContext", "(", ")", "{", "LifeCycle", ".", "call", "(", "this", ")", ";", "/**\n * Context start time\n */", "this", ".", "startTime", "=", "new", "Date", "(", ")", ";", "/**\n * The list of trace levels that the logger context knows about\n */", "this", ".", "logLevel", "=", "new", "LogLevel", "(", ")", ";", "/**\n * Root logger, final ancestor of all loggers\n */", "this", ".", "rootLogger", "=", "new", "Logger", "(", "'[root]'", ",", "this", ")", ";", "/**\n * List of loggers that have been created, indexed by name.\n */", "this", ".", "loggers", "=", "{", "}", ";", "/**\n * List of appenders that have been registered through a call to\n * \"registerAppender\", indexed by name.\n */", "this", ".", "appenders", "=", "{", "}", ";", "/**\n * List of filters that have been registered through a call to\n * \"registerFilter\", indexed by name.\n */", "this", ".", "filters", "=", "{", "}", ";", "/**\n * List of layouts that have been registered through a call to\n * \"registerLayout\", indexed by name.\n */", "this", ".", "layouts", "=", "{", "}", ";", "/**\n * List of appenders that have been instantiated.\n *\n * The list is constructed when the configuration is applied. It is used\n * to start/stop appenders when corresponding functions are called on this\n * context.\n */", "this", ".", "createdAppenders", "=", "[", "]", ";", "/**\n * The context-wide filter.\n *\n * The filter is constructed when the configuration is applied. If the\n * configuration specifies more than one context-wide filter, a\n * CompositeFilter filter is created.\n */", "this", ".", "filter", "=", "null", ";", "/**\n * Flag set when the context is up and running\n */", "this", ".", "started", "=", "false", ";", "/**\n * Log events received by the context before it got a chance to start and\n * that need to be processed as soon as the context is operational\n *\n * The context keeps a maximum of 1000 events in memory. If more events are\n * received before the context becomes operational, the context starts to\n * drop events, replacing the first event with a warning that events had to\n * be droppes. That warning is sent to the root logger.\n */", "this", ".", "pendingEvents", "=", "[", "]", ";", "/**\n * Maximum number of log events that can be stored in the pending list.\n *\n * TODO: adjust this setting based on configuration settings.\n */", "this", ".", "maxPendingEvents", "=", "1000", ";", "/**\n * Number of log events that had to be discarded so far\n */", "this", ".", "discardedPendingEvents", "=", "0", ";", "}" ]
Internal anchor point for the logging system, used by LogManager. @constructor
[ "Internal", "anchor", "point", "for", "the", "logging", "system", "used", "by", "LogManager", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/lib/loggercontext.js#L45-L131
37,572
jldec/marked-forms
marked-forms.js
link
function link(href, title, text) { var reLabelFirst = /^(.*?)\s*\?([^?\s]*)\?(\*?)(X?)(H?)$/; var reLabelAfter = /^\?([^?\s]*)\?(\*?)(X?)(H?)\s*(.*)$/; var m = text.match(reLabelFirst); if (m) return renderInput(m[1], m[2], m[3], m[4], m[5], href, title, true); m = text.match(reLabelAfter); if (m) return renderInput(m[5], m[1], m[2], m[3], m[4], href, title, false); return fallback.link.call(this, href, title, text); }
javascript
function link(href, title, text) { var reLabelFirst = /^(.*?)\s*\?([^?\s]*)\?(\*?)(X?)(H?)$/; var reLabelAfter = /^\?([^?\s]*)\?(\*?)(X?)(H?)\s*(.*)$/; var m = text.match(reLabelFirst); if (m) return renderInput(m[1], m[2], m[3], m[4], m[5], href, title, true); m = text.match(reLabelAfter); if (m) return renderInput(m[5], m[1], m[2], m[3], m[4], href, title, false); return fallback.link.call(this, href, title, text); }
[ "function", "link", "(", "href", ",", "title", ",", "text", ")", "{", "var", "reLabelFirst", "=", "/", "^(.*?)\\s*\\?([^?\\s]*)\\?(\\*?)(X?)(H?)$", "/", ";", "var", "reLabelAfter", "=", "/", "^\\?([^?\\s]*)\\?(\\*?)(X?)(H?)\\s*(.*)$", "/", ";", "var", "m", "=", "text", ".", "match", "(", "reLabelFirst", ")", ";", "if", "(", "m", ")", "return", "renderInput", "(", "m", "[", "1", "]", ",", "m", "[", "2", "]", ",", "m", "[", "3", "]", ",", "m", "[", "4", "]", ",", "m", "[", "5", "]", ",", "href", ",", "title", ",", "true", ")", ";", "m", "=", "text", ".", "match", "(", "reLabelAfter", ")", ";", "if", "(", "m", ")", "return", "renderInput", "(", "m", "[", "5", "]", ",", "m", "[", "1", "]", ",", "m", "[", "2", "]", ",", "m", "[", "3", "]", ",", "m", "[", "4", "]", ",", "href", ",", "title", ",", "false", ")", ";", "return", "fallback", ".", "link", ".", "call", "(", "this", ",", "href", ",", "title", ",", "text", ")", ";", "}" ]
markdown link syntax extension for forms
[ "markdown", "link", "syntax", "extension", "for", "forms" ]
096f0ed19319c83df1a5479782c635fd5ce6281c
https://github.com/jldec/marked-forms/blob/096f0ed19319c83df1a5479782c635fd5ce6281c/marked-forms.js#L40-L52
37,573
jldec/marked-forms
marked-forms.js
listitem
function listitem(text) { if (inList()) { // capture value in trailing "text" - unescape makes regexp work var m = unescapeQuotes(text).match(/^(.*)\s+"([^"]*)"\s*$/); var txt = m ? escapeQuotes(m[1]) : text; var val = m ? escapeQuotes(m[2]) : text; return renderOption(txt, val); } return fallback.listitem.call(this, text); }
javascript
function listitem(text) { if (inList()) { // capture value in trailing "text" - unescape makes regexp work var m = unescapeQuotes(text).match(/^(.*)\s+"([^"]*)"\s*$/); var txt = m ? escapeQuotes(m[1]) : text; var val = m ? escapeQuotes(m[2]) : text; return renderOption(txt, val); } return fallback.listitem.call(this, text); }
[ "function", "listitem", "(", "text", ")", "{", "if", "(", "inList", "(", ")", ")", "{", "// capture value in trailing \"text\" - unescape makes regexp work", "var", "m", "=", "unescapeQuotes", "(", "text", ")", ".", "match", "(", "/", "^(.*)\\s+\"([^\"]*)\"\\s*$", "/", ")", ";", "var", "txt", "=", "m", "?", "escapeQuotes", "(", "m", "[", "1", "]", ")", ":", "text", ";", "var", "val", "=", "m", "?", "escapeQuotes", "(", "m", "[", "2", "]", ")", ":", "text", ";", "return", "renderOption", "(", "txt", ",", "val", ")", ";", "}", "return", "fallback", ".", "listitem", ".", "call", "(", "this", ",", "text", ")", ";", "}" ]
capture listitems for select, checklist, radiolist
[ "capture", "listitems", "for", "select", "checklist", "radiolist" ]
096f0ed19319c83df1a5479782c635fd5ce6281c
https://github.com/jldec/marked-forms/blob/096f0ed19319c83df1a5479782c635fd5ce6281c/marked-forms.js#L55-L67
37,574
jldec/marked-forms
marked-forms.js
list
function list(body, ordered) { if (inList()) return body + endList(); return fallback.list.call(this, body, ordered); }
javascript
function list(body, ordered) { if (inList()) return body + endList(); return fallback.list.call(this, body, ordered); }
[ "function", "list", "(", "body", ",", "ordered", ")", "{", "if", "(", "inList", "(", ")", ")", "return", "body", "+", "endList", "(", ")", ";", "return", "fallback", ".", "list", ".", "call", "(", "this", ",", "body", ",", "ordered", ")", ";", "}" ]
rendering the list terminates listitem collector
[ "rendering", "the", "list", "terminates", "listitem", "collector" ]
096f0ed19319c83df1a5479782c635fd5ce6281c
https://github.com/jldec/marked-forms/blob/096f0ed19319c83df1a5479782c635fd5ce6281c/marked-forms.js#L76-L79
37,575
RoganMurley/hitagi.js
examples/example6/example6.js
function () { this.update = { velocity: function (entity, dt) { entity.c.position.x += hitagi.utils.delta(entity.c.velocity.xspeed, dt); } }; }
javascript
function () { this.update = { velocity: function (entity, dt) { entity.c.position.x += hitagi.utils.delta(entity.c.velocity.xspeed, dt); } }; }
[ "function", "(", ")", "{", "this", ".", "update", "=", "{", "velocity", ":", "function", "(", "entity", ",", "dt", ")", "{", "entity", ".", "c", ".", "position", ".", "x", "+=", "hitagi", ".", "utils", ".", "delta", "(", "entity", ".", "c", ".", "velocity", ".", "xspeed", ",", "dt", ")", ";", "}", "}", ";", "}" ]
We need to update horizontal and vertical velocity seperately for our collision resolution technique. The default hitagi VelocitySystem doesn't support this, but it's easy to make our own.
[ "We", "need", "to", "update", "horizontal", "and", "vertical", "velocity", "seperately", "for", "our", "collision", "resolution", "technique", ".", "The", "default", "hitagi", "VelocitySystem", "doesn", "t", "support", "this", "but", "it", "s", "easy", "to", "make", "our", "own", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/examples/example6/example6.js#L15-L21
37,576
RoganMurley/hitagi.js
examples/example6/example6.js
function (params) { this.$id = 'dragBoxUI'; this.width = 0; this.height = 0; this.origin = { x: params.x, y: params.y }; }
javascript
function (params) { this.$id = 'dragBoxUI'; this.width = 0; this.height = 0; this.origin = { x: params.x, y: params.y }; }
[ "function", "(", "params", ")", "{", "this", ".", "$id", "=", "'dragBoxUI'", ";", "this", ".", "width", "=", "0", ";", "this", ".", "height", "=", "0", ";", "this", ".", "origin", "=", "{", "x", ":", "params", ".", "x", ",", "y", ":", "params", ".", "y", "}", ";", "}" ]
Define components.
[ "Define", "components", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/examples/example6/example6.js#L263-L271
37,577
RoganMurley/hitagi.js
src/components/collision.js
function (params) { params = _.extend({ anchor: { x: 0.5, y: 0.5 } }, params); this.$id = 'collision'; this.$deps = ['position']; this.width = params.width; this.height = params.height; this.anchor = params.anchor; }
javascript
function (params) { params = _.extend({ anchor: { x: 0.5, y: 0.5 } }, params); this.$id = 'collision'; this.$deps = ['position']; this.width = params.width; this.height = params.height; this.anchor = params.anchor; }
[ "function", "(", "params", ")", "{", "params", "=", "_", ".", "extend", "(", "{", "anchor", ":", "{", "x", ":", "0.5", ",", "y", ":", "0.5", "}", "}", ",", "params", ")", ";", "this", ".", "$id", "=", "'collision'", ";", "this", ".", "$deps", "=", "[", "'position'", "]", ";", "this", ".", "width", "=", "params", ".", "width", ";", "this", ".", "height", "=", "params", ".", "height", ";", "this", ".", "anchor", "=", "params", ".", "anchor", ";", "}" ]
Represents the collision boundaries of an entity.
[ "Represents", "the", "collision", "boundaries", "of", "an", "entity", "." ]
6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053
https://github.com/RoganMurley/hitagi.js/blob/6ad88d8df3af9b1708d70bb0c1f5a7a39ead9053/src/components/collision.js#L7-L21
37,578
njoubert/node-groupme
lib/Stateless.js
getRequest
function getRequest(at, api_url, config, callback) { if (!config.responseCode) config.responseCode = 200; request( { uri: getURL(at, api_url, config.opts), method: 'GET', headers: {'Content-Type': 'application/json'} }, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
javascript
function getRequest(at, api_url, config, callback) { if (!config.responseCode) config.responseCode = 200; request( { uri: getURL(at, api_url, config.opts), method: 'GET', headers: {'Content-Type': 'application/json'} }, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
[ "function", "getRequest", "(", "at", ",", "api_url", ",", "config", ",", "callback", ")", "{", "if", "(", "!", "config", ".", "responseCode", ")", "config", ".", "responseCode", "=", "200", ";", "request", "(", "{", "uri", ":", "getURL", "(", "at", ",", "api_url", ",", "config", ".", "opts", ")", ",", "method", ":", "'GET'", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/json'", "}", "}", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "if", "(", "!", "err", "&&", "res", ".", "statusCode", "==", "config", ".", "responseCode", ")", "{", "if", "(", "config", ".", "doParse", ")", "{", "callback", "(", "null", ",", "JSON", ".", "parse", "(", "body", ")", ".", "response", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "res", ".", "statusCode", ")", ";", "}", "}", "else", "{", "callback", "(", "res", ")", "}", "}", ")", ";", "}" ]
This makes one of many different types of post requests. config.opts - this adds additional parameters to the url config.doParse - if true, parses the return value as json config.responseCode - if set, checks for this response code
[ "This", "makes", "one", "of", "many", "different", "types", "of", "post", "requests", ".", "config", ".", "opts", "-", "this", "adds", "additional", "parameters", "to", "the", "url", "config", ".", "doParse", "-", "if", "true", "parses", "the", "return", "value", "as", "json", "config", ".", "responseCode", "-", "if", "set", "checks", "for", "this", "response", "code" ]
0d242fb41db4efa3edd9cd332626640623f8493b
https://github.com/njoubert/node-groupme/blob/0d242fb41db4efa3edd9cd332626640623f8493b/lib/Stateless.js#L36-L58
37,579
njoubert/node-groupme
lib/Stateless.js
postRequest
function postRequest(at, api_url, config, callback) { var r_opts = { uri: getURL(at, api_url), method: 'POST', headers: {'Content-Type': 'application/json'} }; if (config.body && !config.form) { r_opts.body = JSON.stringify(config.body); } else { r_opts.form = config.form; } if (!config.responseCode) config.responseCode = 200; request( r_opts, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
javascript
function postRequest(at, api_url, config, callback) { var r_opts = { uri: getURL(at, api_url), method: 'POST', headers: {'Content-Type': 'application/json'} }; if (config.body && !config.form) { r_opts.body = JSON.stringify(config.body); } else { r_opts.form = config.form; } if (!config.responseCode) config.responseCode = 200; request( r_opts, function(err,res,body) { if (!err && res.statusCode == config.responseCode) { if (config.doParse) { callback(null,JSON.parse(body).response); } else { callback(null,res.statusCode); } } else { callback(res) } }); }
[ "function", "postRequest", "(", "at", ",", "api_url", ",", "config", ",", "callback", ")", "{", "var", "r_opts", "=", "{", "uri", ":", "getURL", "(", "at", ",", "api_url", ")", ",", "method", ":", "'POST'", ",", "headers", ":", "{", "'Content-Type'", ":", "'application/json'", "}", "}", ";", "if", "(", "config", ".", "body", "&&", "!", "config", ".", "form", ")", "{", "r_opts", ".", "body", "=", "JSON", ".", "stringify", "(", "config", ".", "body", ")", ";", "}", "else", "{", "r_opts", ".", "form", "=", "config", ".", "form", ";", "}", "if", "(", "!", "config", ".", "responseCode", ")", "config", ".", "responseCode", "=", "200", ";", "request", "(", "r_opts", ",", "function", "(", "err", ",", "res", ",", "body", ")", "{", "if", "(", "!", "err", "&&", "res", ".", "statusCode", "==", "config", ".", "responseCode", ")", "{", "if", "(", "config", ".", "doParse", ")", "{", "callback", "(", "null", ",", "JSON", ".", "parse", "(", "body", ")", ".", "response", ")", ";", "}", "else", "{", "callback", "(", "null", ",", "res", ".", "statusCode", ")", ";", "}", "}", "else", "{", "callback", "(", "res", ")", "}", "}", ")", ";", "}" ]
This makes one of many different types of post requests. config.body - this stingifies the object as the POST body config.form - this sets the POST body as form parameters config.doParse - if true, parses the return value as json config.responseCode - if set, checks for this response code
[ "This", "makes", "one", "of", "many", "different", "types", "of", "post", "requests", ".", "config", ".", "body", "-", "this", "stingifies", "the", "object", "as", "the", "POST", "body", "config", ".", "form", "-", "this", "sets", "the", "POST", "body", "as", "form", "parameters", "config", ".", "doParse", "-", "if", "true", "parses", "the", "return", "value", "as", "json", "config", ".", "responseCode", "-", "if", "set", "checks", "for", "this", "response", "code" ]
0d242fb41db4efa3edd9cd332626640623f8493b
https://github.com/njoubert/node-groupme/blob/0d242fb41db4efa3edd9cd332626640623f8493b/lib/Stateless.js#L65-L96
37,580
commenthol/clones
src/index.js
clones
function clones (source, bind, target) { let opts = { bind: bind, visited: [], cloned: [] } return _clone(opts, source, target) }
javascript
function clones (source, bind, target) { let opts = { bind: bind, visited: [], cloned: [] } return _clone(opts, source, target) }
[ "function", "clones", "(", "source", ",", "bind", ",", "target", ")", "{", "let", "opts", "=", "{", "bind", ":", "bind", ",", "visited", ":", "[", "]", ",", "cloned", ":", "[", "]", "}", "return", "_clone", "(", "opts", ",", "source", ",", "target", ")", "}" ]
A Deep-Clone of object `source` @static @param {Object} source - clone source @param {Object} [bind] - bind functions to this context @return {Any} deep clone of `source` @example const clones = require('clones') const source = [ {a: {b: 1}}, {c: {d: 2}}, '3', function () { return 4 } ] // adding circularities source[0].a.e = source[0].a const dest = clones(source) // => [{ a: { b: 1, e: [Circular] } }, // { c: { d: 2 } }, // '3', // [Function] ]
[ "A", "Deep", "-", "Clone", "of", "object", "source" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L33-L40
37,581
commenthol/clones
src/index.js
_clone
function _clone (opts, source, target) { let type = toType(source) switch (type) { case 'String': case 'Number': case 'Boolean': case 'Null': case 'Undefined': case 'Symbol': case 'DOMPrototype': // (browser) case 'process': // (node) cloning this is not a good idea target = source break case 'Function': if (!target) { let _bind = (opts.bind === null ? null : opts.bind || source) if (opts.wrapFn) { target = function () { return source.apply(_bind, arguments) } } else { target = source.bind(_bind) } } target = _props(opts, source, target) break case 'Int8Array': case 'Uint8Array': case 'Uint8ClampedArray': case 'Int16Array': case 'Uint16Array': case 'Int32Array': case 'Uint32Array': case 'Float32Array': case 'Float64Array': target = new source.constructor(source) break case 'Array': target = source.map(function (item) { return _clone(opts, item) }) target = _props(opts, source, target) break case 'Date': target = new Date(source) break case 'Error': case 'EvalError': case 'InternalError': case 'RangeError': case 'ReferenceError': case 'SyntaxError': case 'TypeError': case 'URIError': target = new source.constructor(source.message) target = _props(opts, source, target) target.stack = source.stack break case 'RegExp': let flags = source.flags || (source.global ? 'g' : '') + (source.ignoreCase ? 'i' : '') + (source.multiline ? 'm' : '') target = new RegExp(source.source, flags) break case 'Buffer': target = new source.constructor(source) break case 'Window': // clone of global object case 'global': opts.wrapFn = true target = _props(opts, source, target || {}) break case 'Math': case 'JSON': case 'Console': case 'Navigator': case 'Screen': case 'Object': target = _props(opts, source, target || {}) break default: if (/^HTML/.test(type)) { // handle HTMLElements if (source.cloneNode) { target = source.cloneNode(true) } else { target = source } } else if (typeof source === 'object') { // handle other object based types target = _props(opts, source, target || {}) } else { // anything else should be a primitive target = source } } return target }
javascript
function _clone (opts, source, target) { let type = toType(source) switch (type) { case 'String': case 'Number': case 'Boolean': case 'Null': case 'Undefined': case 'Symbol': case 'DOMPrototype': // (browser) case 'process': // (node) cloning this is not a good idea target = source break case 'Function': if (!target) { let _bind = (opts.bind === null ? null : opts.bind || source) if (opts.wrapFn) { target = function () { return source.apply(_bind, arguments) } } else { target = source.bind(_bind) } } target = _props(opts, source, target) break case 'Int8Array': case 'Uint8Array': case 'Uint8ClampedArray': case 'Int16Array': case 'Uint16Array': case 'Int32Array': case 'Uint32Array': case 'Float32Array': case 'Float64Array': target = new source.constructor(source) break case 'Array': target = source.map(function (item) { return _clone(opts, item) }) target = _props(opts, source, target) break case 'Date': target = new Date(source) break case 'Error': case 'EvalError': case 'InternalError': case 'RangeError': case 'ReferenceError': case 'SyntaxError': case 'TypeError': case 'URIError': target = new source.constructor(source.message) target = _props(opts, source, target) target.stack = source.stack break case 'RegExp': let flags = source.flags || (source.global ? 'g' : '') + (source.ignoreCase ? 'i' : '') + (source.multiline ? 'm' : '') target = new RegExp(source.source, flags) break case 'Buffer': target = new source.constructor(source) break case 'Window': // clone of global object case 'global': opts.wrapFn = true target = _props(opts, source, target || {}) break case 'Math': case 'JSON': case 'Console': case 'Navigator': case 'Screen': case 'Object': target = _props(opts, source, target || {}) break default: if (/^HTML/.test(type)) { // handle HTMLElements if (source.cloneNode) { target = source.cloneNode(true) } else { target = source } } else if (typeof source === 'object') { // handle other object based types target = _props(opts, source, target || {}) } else { // anything else should be a primitive target = source } } return target }
[ "function", "_clone", "(", "opts", ",", "source", ",", "target", ")", "{", "let", "type", "=", "toType", "(", "source", ")", "switch", "(", "type", ")", "{", "case", "'String'", ":", "case", "'Number'", ":", "case", "'Boolean'", ":", "case", "'Null'", ":", "case", "'Undefined'", ":", "case", "'Symbol'", ":", "case", "'DOMPrototype'", ":", "// (browser)", "case", "'process'", ":", "// (node) cloning this is not a good idea", "target", "=", "source", "break", "case", "'Function'", ":", "if", "(", "!", "target", ")", "{", "let", "_bind", "=", "(", "opts", ".", "bind", "===", "null", "?", "null", ":", "opts", ".", "bind", "||", "source", ")", "if", "(", "opts", ".", "wrapFn", ")", "{", "target", "=", "function", "(", ")", "{", "return", "source", ".", "apply", "(", "_bind", ",", "arguments", ")", "}", "}", "else", "{", "target", "=", "source", ".", "bind", "(", "_bind", ")", "}", "}", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", ")", "break", "case", "'Int8Array'", ":", "case", "'Uint8Array'", ":", "case", "'Uint8ClampedArray'", ":", "case", "'Int16Array'", ":", "case", "'Uint16Array'", ":", "case", "'Int32Array'", ":", "case", "'Uint32Array'", ":", "case", "'Float32Array'", ":", "case", "'Float64Array'", ":", "target", "=", "new", "source", ".", "constructor", "(", "source", ")", "break", "case", "'Array'", ":", "target", "=", "source", ".", "map", "(", "function", "(", "item", ")", "{", "return", "_clone", "(", "opts", ",", "item", ")", "}", ")", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", ")", "break", "case", "'Date'", ":", "target", "=", "new", "Date", "(", "source", ")", "break", "case", "'Error'", ":", "case", "'EvalError'", ":", "case", "'InternalError'", ":", "case", "'RangeError'", ":", "case", "'ReferenceError'", ":", "case", "'SyntaxError'", ":", "case", "'TypeError'", ":", "case", "'URIError'", ":", "target", "=", "new", "source", ".", "constructor", "(", "source", ".", "message", ")", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", ")", "target", ".", "stack", "=", "source", ".", "stack", "break", "case", "'RegExp'", ":", "let", "flags", "=", "source", ".", "flags", "||", "(", "source", ".", "global", "?", "'g'", ":", "''", ")", "+", "(", "source", ".", "ignoreCase", "?", "'i'", ":", "''", ")", "+", "(", "source", ".", "multiline", "?", "'m'", ":", "''", ")", "target", "=", "new", "RegExp", "(", "source", ".", "source", ",", "flags", ")", "break", "case", "'Buffer'", ":", "target", "=", "new", "source", ".", "constructor", "(", "source", ")", "break", "case", "'Window'", ":", "// clone of global object", "case", "'global'", ":", "opts", ".", "wrapFn", "=", "true", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", "||", "{", "}", ")", "break", "case", "'Math'", ":", "case", "'JSON'", ":", "case", "'Console'", ":", "case", "'Navigator'", ":", "case", "'Screen'", ":", "case", "'Object'", ":", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", "||", "{", "}", ")", "break", "default", ":", "if", "(", "/", "^HTML", "/", ".", "test", "(", "type", ")", ")", "{", "// handle HTMLElements", "if", "(", "source", ".", "cloneNode", ")", "{", "target", "=", "source", ".", "cloneNode", "(", "true", ")", "}", "else", "{", "target", "=", "source", "}", "}", "else", "if", "(", "typeof", "source", "===", "'object'", ")", "{", "// handle other object based types", "target", "=", "_props", "(", "opts", ",", "source", ",", "target", "||", "{", "}", ")", "}", "else", "{", "// anything else should be a primitive", "target", "=", "source", "}", "}", "return", "target", "}" ]
Recursively clone source @static @private @param {Object} opts - options @param {Object} [opts.bind] - optional bind for function clones @param {Array} opts.visited - visited references to detect circularities @param {Array} opts.cloned - visited references of clones to assign circularities @param {Any} source - The object to clone @return {Any} deep clone of `source`
[ "Recursively", "clone", "source" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L81-L176
37,582
commenthol/clones
src/index.js
_props
function _props (opts, source, target) { let idx = opts.visited.indexOf(source) // check for circularities if (idx === -1) { opts.visited.push(source) opts.cloned.push(target) Object.getOwnPropertyNames(source).forEach(function (key) { if (key === 'prototype') { target[key] = Object.create(source[key]) Object.getOwnPropertyNames(source[key]).forEach(function (p) { if (p !== 'constructor') { _descriptor(opts, source[key], target[key], p) // } else { // target[key][p] = target // Safari may throw here with TypeError: Attempted to assign to readonly property. } }) } else { _descriptor(opts, source, target, key) } }) opts.visited.pop() opts.cloned.pop() } else { target = opts.cloned[idx] // add reference of circularity } return target }
javascript
function _props (opts, source, target) { let idx = opts.visited.indexOf(source) // check for circularities if (idx === -1) { opts.visited.push(source) opts.cloned.push(target) Object.getOwnPropertyNames(source).forEach(function (key) { if (key === 'prototype') { target[key] = Object.create(source[key]) Object.getOwnPropertyNames(source[key]).forEach(function (p) { if (p !== 'constructor') { _descriptor(opts, source[key], target[key], p) // } else { // target[key][p] = target // Safari may throw here with TypeError: Attempted to assign to readonly property. } }) } else { _descriptor(opts, source, target, key) } }) opts.visited.pop() opts.cloned.pop() } else { target = opts.cloned[idx] // add reference of circularity } return target }
[ "function", "_props", "(", "opts", ",", "source", ",", "target", ")", "{", "let", "idx", "=", "opts", ".", "visited", ".", "indexOf", "(", "source", ")", "// check for circularities", "if", "(", "idx", "===", "-", "1", ")", "{", "opts", ".", "visited", ".", "push", "(", "source", ")", "opts", ".", "cloned", ".", "push", "(", "target", ")", "Object", ".", "getOwnPropertyNames", "(", "source", ")", ".", "forEach", "(", "function", "(", "key", ")", "{", "if", "(", "key", "===", "'prototype'", ")", "{", "target", "[", "key", "]", "=", "Object", ".", "create", "(", "source", "[", "key", "]", ")", "Object", ".", "getOwnPropertyNames", "(", "source", "[", "key", "]", ")", ".", "forEach", "(", "function", "(", "p", ")", "{", "if", "(", "p", "!==", "'constructor'", ")", "{", "_descriptor", "(", "opts", ",", "source", "[", "key", "]", ",", "target", "[", "key", "]", ",", "p", ")", "// } else {", "// target[key][p] = target", "// Safari may throw here with TypeError: Attempted to assign to readonly property.", "}", "}", ")", "}", "else", "{", "_descriptor", "(", "opts", ",", "source", ",", "target", ",", "key", ")", "}", "}", ")", "opts", ".", "visited", ".", "pop", "(", ")", "opts", ".", "cloned", ".", "pop", "(", ")", "}", "else", "{", "target", "=", "opts", ".", "cloned", "[", "idx", "]", "// add reference of circularity", "}", "return", "target", "}" ]
Clone property while cloning circularities @static @private @param {Object} opts - options @param {Any} source - source object @param {Any} [target] - target object @returns {Any} target
[ "Clone", "property", "while", "cloning", "circularities" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L188-L214
37,583
commenthol/clones
src/index.js
_descriptor
function _descriptor (opts, source, target, key) { let desc = Object.getOwnPropertyDescriptor(source, key) if (desc) { if (desc.writable) { desc.value = _clone(opts, desc.value) } try { Object.defineProperty(target, key, desc) } catch (e) { // Safari throws with TypeError: // Attempting to change access mechanism for an unconfigurable property. // Attempting to change value of a readonly property. if (!'Attempting to change'.indexOf(e.message)) { throw e } } } }
javascript
function _descriptor (opts, source, target, key) { let desc = Object.getOwnPropertyDescriptor(source, key) if (desc) { if (desc.writable) { desc.value = _clone(opts, desc.value) } try { Object.defineProperty(target, key, desc) } catch (e) { // Safari throws with TypeError: // Attempting to change access mechanism for an unconfigurable property. // Attempting to change value of a readonly property. if (!'Attempting to change'.indexOf(e.message)) { throw e } } } }
[ "function", "_descriptor", "(", "opts", ",", "source", ",", "target", ",", "key", ")", "{", "let", "desc", "=", "Object", ".", "getOwnPropertyDescriptor", "(", "source", ",", "key", ")", "if", "(", "desc", ")", "{", "if", "(", "desc", ".", "writable", ")", "{", "desc", ".", "value", "=", "_clone", "(", "opts", ",", "desc", ".", "value", ")", "}", "try", "{", "Object", ".", "defineProperty", "(", "target", ",", "key", ",", "desc", ")", "}", "catch", "(", "e", ")", "{", "// Safari throws with TypeError:", "// Attempting to change access mechanism for an unconfigurable property.", "// Attempting to change value of a readonly property.", "if", "(", "!", "'Attempting to change'", ".", "indexOf", "(", "e", ".", "message", ")", ")", "{", "throw", "e", "}", "}", "}", "}" ]
assign descriptor with property `key` from source to target @private
[ "assign", "descriptor", "with", "property", "key", "from", "source", "to", "target" ]
dd9d357948c949bd10a818d1f36e64b4d89c35b4
https://github.com/commenthol/clones/blob/dd9d357948c949bd10a818d1f36e64b4d89c35b4/src/index.js#L220-L237
37,584
atomantic/undermore
gulp/tasks/undermore.js
cleanContent
function cleanContent() { function transform(file, cb) { file.contents = new Buffer((function (src) { var lines = src.replace('_.mixin({\n','').split('\n'), last = lines.pop(); // handle empty lines at the end of the file while(last===''){ last = lines.pop(); } return lines.join('\n'); })(String(file.contents))); cb(null, file); } return require('event-stream').map(transform); }
javascript
function cleanContent() { function transform(file, cb) { file.contents = new Buffer((function (src) { var lines = src.replace('_.mixin({\n','').split('\n'), last = lines.pop(); // handle empty lines at the end of the file while(last===''){ last = lines.pop(); } return lines.join('\n'); })(String(file.contents))); cb(null, file); } return require('event-stream').map(transform); }
[ "function", "cleanContent", "(", ")", "{", "function", "transform", "(", "file", ",", "cb", ")", "{", "file", ".", "contents", "=", "new", "Buffer", "(", "(", "function", "(", "src", ")", "{", "var", "lines", "=", "src", ".", "replace", "(", "'_.mixin({\\n'", ",", "''", ")", ".", "split", "(", "'\\n'", ")", ",", "last", "=", "lines", ".", "pop", "(", ")", ";", "// handle empty lines at the end of the file", "while", "(", "last", "===", "''", ")", "{", "last", "=", "lines", ".", "pop", "(", ")", ";", "}", "return", "lines", ".", "join", "(", "'\\n'", ")", ";", "}", ")", "(", "String", "(", "file", ".", "contents", ")", ")", ")", ";", "cb", "(", "null", ",", "file", ")", ";", "}", "return", "require", "(", "'event-stream'", ")", ".", "map", "(", "transform", ")", ";", "}" ]
This method is used as a modifier for minification to clean up the stream a bit.
[ "This", "method", "is", "used", "as", "a", "modifier", "for", "minification", "to", "clean", "up", "the", "stream", "a", "bit", "." ]
6c6d995460c25c1df087b465fdc4d21035b4c7b2
https://github.com/atomantic/undermore/blob/6c6d995460c25c1df087b465fdc4d21035b4c7b2/gulp/tasks/undermore.js#L16-L31
37,585
ToMMApps/express-waf
express-waf.js
recursiveCall
function recursiveCall(i, callback) { if(i >= _modules.length) { callback(); } else { _modules[i].check(req, res, function () { recursiveCall(++i, callback); }) } }
javascript
function recursiveCall(i, callback) { if(i >= _modules.length) { callback(); } else { _modules[i].check(req, res, function () { recursiveCall(++i, callback); }) } }
[ "function", "recursiveCall", "(", "i", ",", "callback", ")", "{", "if", "(", "i", ">=", "_modules", ".", "length", ")", "{", "callback", "(", ")", ";", "}", "else", "{", "_modules", "[", "i", "]", ".", "check", "(", "req", ",", "res", ",", "function", "(", ")", "{", "recursiveCall", "(", "++", "i", ",", "callback", ")", ";", "}", ")", "}", "}" ]
This iterates over all modules and run on them function check @param i {int} iterator @param callback {function} Callback after iteration ended
[ "This", "iterates", "over", "all", "modules", "and", "run", "on", "them", "function", "check" ]
5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a
https://github.com/ToMMApps/express-waf/blob/5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a/express-waf.js#L43-L51
37,586
joshfire/woodman
lib/message.js
function (params) { this.formatString = ''; this.params = []; if (!params) { return; } params = utils.isArray(params) ? params : [params]; if ((params.length > 0) && utils.isString(params[0]) && (params[0].indexOf('{}') !== -1)) { this.formatString = params[0]; this.params = params.slice(1); } else { this.params = params; } }
javascript
function (params) { this.formatString = ''; this.params = []; if (!params) { return; } params = utils.isArray(params) ? params : [params]; if ((params.length > 0) && utils.isString(params[0]) && (params[0].indexOf('{}') !== -1)) { this.formatString = params[0]; this.params = params.slice(1); } else { this.params = params; } }
[ "function", "(", "params", ")", "{", "this", ".", "formatString", "=", "''", ";", "this", ".", "params", "=", "[", "]", ";", "if", "(", "!", "params", ")", "{", "return", ";", "}", "params", "=", "utils", ".", "isArray", "(", "params", ")", "?", "params", ":", "[", "params", "]", ";", "if", "(", "(", "params", ".", "length", ">", "0", ")", "&&", "utils", ".", "isString", "(", "params", "[", "0", "]", ")", "&&", "(", "params", "[", "0", "]", ".", "indexOf", "(", "'{}'", ")", "!==", "-", "1", ")", ")", "{", "this", ".", "formatString", "=", "params", "[", "0", "]", ";", "this", ".", "params", "=", "params", ".", "slice", "(", "1", ")", ";", "}", "else", "{", "this", ".", "params", "=", "params", ";", "}", "}" ]
Definition of the Message class. If the first parameter in the message is a string that contains "{}", it is taken to be a format string, and the getFormattedMessage function will substitute the occurrences of "{}" with the serialization of the other parameters in order. @constructor @param {(string|Object|Array.<(string|Object)>)} params The parameters that compose the message.
[ "Definition", "of", "the", "Message", "class", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/lib/message.js#L47-L65
37,587
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/jquery.colorbox.js
setSize
function setSize(size, dimension) { return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); }
javascript
function setSize(size, dimension) { return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10)); }
[ "function", "setSize", "(", "size", ",", "dimension", ")", "{", "return", "Math", ".", "round", "(", "(", "/", "%", "/", ".", "test", "(", "size", ")", "?", "(", "(", "dimension", "===", "'x'", "?", "$window", ".", "width", "(", ")", ":", "winheight", "(", ")", ")", "/", "100", ")", ":", "1", ")", "*", "parseInt", "(", "size", ",", "10", ")", ")", ";", "}" ]
Convert '%' and 'px' values to integers
[ "Convert", "%", "and", "px", "values", "to", "integers" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/jquery.colorbox.js#L171-L173
37,588
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/jquery.colorbox.js
appendHTML
function appendHTML() { if (!$box && document.body) { init = false; $window = $(window); $box = $tag(div).attr({ id: colorbox, 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS. role: 'dialog', tabindex: '-1' }).hide(); $overlay = $tag(div, "Overlay").hide(); $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); $wrap = $tag(div, "Wrapper"); $content = $tag(div, "Content").append( $title = $tag(div, "Title"), $current = $tag(div, "Current"), $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}), $next = $('<button type="button"/>').attr({id:prefix+'Next'}), $slideshow = $tag('button', "Slideshow"), $loadingOverlay ); $close = $('<button type="button"/>').attr({id:prefix+'Close'}); $wrap.append( // The 3x3 Grid that makes up Colorbox $tag(div).append( $tag(div, "TopLeft"), $topBorder = $tag(div, "TopCenter"), $tag(div, "TopRight") ), $tag(div, false, 'clear:left').append( $leftBorder = $tag(div, "MiddleLeft"), $content, $rightBorder = $tag(div, "MiddleRight") ), $tag(div, false, 'clear:left').append( $tag(div, "BottomLeft"), $bottomBorder = $tag(div, "BottomCenter"), $tag(div, "BottomRight") ) ).find('div div').css({'float': 'left'}); $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none'); $groupControls = $next.add($prev).add($current).add($slideshow); $(document.body).append($overlay, $box.append($wrap, $loadingBay)); } }
javascript
function appendHTML() { if (!$box && document.body) { init = false; $window = $(window); $box = $tag(div).attr({ id: colorbox, 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS. role: 'dialog', tabindex: '-1' }).hide(); $overlay = $tag(div, "Overlay").hide(); $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]); $wrap = $tag(div, "Wrapper"); $content = $tag(div, "Content").append( $title = $tag(div, "Title"), $current = $tag(div, "Current"), $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}), $next = $('<button type="button"/>').attr({id:prefix+'Next'}), $slideshow = $tag('button', "Slideshow"), $loadingOverlay ); $close = $('<button type="button"/>').attr({id:prefix+'Close'}); $wrap.append( // The 3x3 Grid that makes up Colorbox $tag(div).append( $tag(div, "TopLeft"), $topBorder = $tag(div, "TopCenter"), $tag(div, "TopRight") ), $tag(div, false, 'clear:left').append( $leftBorder = $tag(div, "MiddleLeft"), $content, $rightBorder = $tag(div, "MiddleRight") ), $tag(div, false, 'clear:left').append( $tag(div, "BottomLeft"), $bottomBorder = $tag(div, "BottomCenter"), $tag(div, "BottomRight") ) ).find('div div').css({'float': 'left'}); $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none'); $groupControls = $next.add($prev).add($current).add($slideshow); $(document.body).append($overlay, $box.append($wrap, $loadingBay)); } }
[ "function", "appendHTML", "(", ")", "{", "if", "(", "!", "$box", "&&", "document", ".", "body", ")", "{", "init", "=", "false", ";", "$window", "=", "$", "(", "window", ")", ";", "$box", "=", "$tag", "(", "div", ")", ".", "attr", "(", "{", "id", ":", "colorbox", ",", "'class'", ":", "$", ".", "support", ".", "opacity", "===", "false", "?", "prefix", "+", "'IE'", ":", "''", ",", "// class for optional IE8 & lower targeted CSS.", "role", ":", "'dialog'", ",", "tabindex", ":", "'-1'", "}", ")", ".", "hide", "(", ")", ";", "$overlay", "=", "$tag", "(", "div", ",", "\"Overlay\"", ")", ".", "hide", "(", ")", ";", "$loadingOverlay", "=", "$", "(", "[", "$tag", "(", "div", ",", "\"LoadingOverlay\"", ")", "[", "0", "]", ",", "$tag", "(", "div", ",", "\"LoadingGraphic\"", ")", "[", "0", "]", "]", ")", ";", "$wrap", "=", "$tag", "(", "div", ",", "\"Wrapper\"", ")", ";", "$content", "=", "$tag", "(", "div", ",", "\"Content\"", ")", ".", "append", "(", "$title", "=", "$tag", "(", "div", ",", "\"Title\"", ")", ",", "$current", "=", "$tag", "(", "div", ",", "\"Current\"", ")", ",", "$prev", "=", "$", "(", "'<button type=\"button\"/>'", ")", ".", "attr", "(", "{", "id", ":", "prefix", "+", "'Previous'", "}", ")", ",", "$next", "=", "$", "(", "'<button type=\"button\"/>'", ")", ".", "attr", "(", "{", "id", ":", "prefix", "+", "'Next'", "}", ")", ",", "$slideshow", "=", "$tag", "(", "'button'", ",", "\"Slideshow\"", ")", ",", "$loadingOverlay", ")", ";", "$close", "=", "$", "(", "'<button type=\"button\"/>'", ")", ".", "attr", "(", "{", "id", ":", "prefix", "+", "'Close'", "}", ")", ";", "$wrap", ".", "append", "(", "// The 3x3 Grid that makes up Colorbox", "$tag", "(", "div", ")", ".", "append", "(", "$tag", "(", "div", ",", "\"TopLeft\"", ")", ",", "$topBorder", "=", "$tag", "(", "div", ",", "\"TopCenter\"", ")", ",", "$tag", "(", "div", ",", "\"TopRight\"", ")", ")", ",", "$tag", "(", "div", ",", "false", ",", "'clear:left'", ")", ".", "append", "(", "$leftBorder", "=", "$tag", "(", "div", ",", "\"MiddleLeft\"", ")", ",", "$content", ",", "$rightBorder", "=", "$tag", "(", "div", ",", "\"MiddleRight\"", ")", ")", ",", "$tag", "(", "div", ",", "false", ",", "'clear:left'", ")", ".", "append", "(", "$tag", "(", "div", ",", "\"BottomLeft\"", ")", ",", "$bottomBorder", "=", "$tag", "(", "div", ",", "\"BottomCenter\"", ")", ",", "$tag", "(", "div", ",", "\"BottomRight\"", ")", ")", ")", ".", "find", "(", "'div div'", ")", ".", "css", "(", "{", "'float'", ":", "'left'", "}", ")", ";", "$loadingBay", "=", "$tag", "(", "div", ",", "false", ",", "'position:absolute; width:9999px; visibility:hidden; display:none'", ")", ";", "$groupControls", "=", "$next", ".", "add", "(", "$prev", ")", ".", "add", "(", "$current", ")", ".", "add", "(", "$slideshow", ")", ";", "$", "(", "document", ".", "body", ")", ".", "append", "(", "$overlay", ",", "$box", ".", "append", "(", "$wrap", ",", "$loadingBay", ")", ")", ";", "}", "}" ]
Colorbox's markup needs to be added to the DOM prior to being called so that the browser will go ahead and load the CSS background images.
[ "Colorbox", "s", "markup", "needs", "to", "be", "added", "to", "the", "DOM", "prior", "to", "being", "called", "so", "that", "the", "browser", "will", "go", "ahead", "and", "load", "the", "CSS", "background", "images", "." ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/jquery.colorbox.js#L406-L454
37,589
infrabel/themes-gnap
raw/ace/assets/js/uncompressed/jquery.colorbox.js
addBindings
function addBindings() { function clickHandler(e) { // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt. // See: http://jacklmoore.com/notes/click-events/ if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) { e.preventDefault(); launch(this); } } if ($box) { if (!init) { init = true; // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly. $next.click(function () { publicMethod.next(); }); $prev.click(function () { publicMethod.prev(); }); $close.click(function () { publicMethod.close(); }); $overlay.click(function () { if (settings.overlayClose) { publicMethod.close(); } }); // Key Bindings $(document).bind('keydown.' + prefix, function (e) { var key = e.keyCode; if (open && settings.escKey && key === 27) { e.preventDefault(); publicMethod.close(); } if (open && settings.arrowKey && $related[1] && !e.altKey) { if (key === 37) { e.preventDefault(); $prev.click(); } else if (key === 39) { e.preventDefault(); $next.click(); } } }); if ($.isFunction($.fn.on)) { // For jQuery 1.7+ $(document).on('click.'+prefix, '.'+boxElement, clickHandler); } else { // For jQuery 1.3.x -> 1.6.x // This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed. // This is not here for jQuery 1.9, it's here for legacy users. $('.'+boxElement).live('click.'+prefix, clickHandler); } } return true; } return false; }
javascript
function addBindings() { function clickHandler(e) { // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt. // See: http://jacklmoore.com/notes/click-events/ if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) { e.preventDefault(); launch(this); } } if ($box) { if (!init) { init = true; // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly. $next.click(function () { publicMethod.next(); }); $prev.click(function () { publicMethod.prev(); }); $close.click(function () { publicMethod.close(); }); $overlay.click(function () { if (settings.overlayClose) { publicMethod.close(); } }); // Key Bindings $(document).bind('keydown.' + prefix, function (e) { var key = e.keyCode; if (open && settings.escKey && key === 27) { e.preventDefault(); publicMethod.close(); } if (open && settings.arrowKey && $related[1] && !e.altKey) { if (key === 37) { e.preventDefault(); $prev.click(); } else if (key === 39) { e.preventDefault(); $next.click(); } } }); if ($.isFunction($.fn.on)) { // For jQuery 1.7+ $(document).on('click.'+prefix, '.'+boxElement, clickHandler); } else { // For jQuery 1.3.x -> 1.6.x // This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed. // This is not here for jQuery 1.9, it's here for legacy users. $('.'+boxElement).live('click.'+prefix, clickHandler); } } return true; } return false; }
[ "function", "addBindings", "(", ")", "{", "function", "clickHandler", "(", "e", ")", "{", "// ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.", "// See: http://jacklmoore.com/notes/click-events/", "if", "(", "!", "(", "e", ".", "which", ">", "1", "||", "e", ".", "shiftKey", "||", "e", ".", "altKey", "||", "e", ".", "metaKey", "||", "e", ".", "ctrlKey", ")", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "launch", "(", "this", ")", ";", "}", "}", "if", "(", "$box", ")", "{", "if", "(", "!", "init", ")", "{", "init", "=", "true", ";", "// Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.", "$next", ".", "click", "(", "function", "(", ")", "{", "publicMethod", ".", "next", "(", ")", ";", "}", ")", ";", "$prev", ".", "click", "(", "function", "(", ")", "{", "publicMethod", ".", "prev", "(", ")", ";", "}", ")", ";", "$close", ".", "click", "(", "function", "(", ")", "{", "publicMethod", ".", "close", "(", ")", ";", "}", ")", ";", "$overlay", ".", "click", "(", "function", "(", ")", "{", "if", "(", "settings", ".", "overlayClose", ")", "{", "publicMethod", ".", "close", "(", ")", ";", "}", "}", ")", ";", "// Key Bindings", "$", "(", "document", ")", ".", "bind", "(", "'keydown.'", "+", "prefix", ",", "function", "(", "e", ")", "{", "var", "key", "=", "e", ".", "keyCode", ";", "if", "(", "open", "&&", "settings", ".", "escKey", "&&", "key", "===", "27", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "publicMethod", ".", "close", "(", ")", ";", "}", "if", "(", "open", "&&", "settings", ".", "arrowKey", "&&", "$related", "[", "1", "]", "&&", "!", "e", ".", "altKey", ")", "{", "if", "(", "key", "===", "37", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "$prev", ".", "click", "(", ")", ";", "}", "else", "if", "(", "key", "===", "39", ")", "{", "e", ".", "preventDefault", "(", ")", ";", "$next", ".", "click", "(", ")", ";", "}", "}", "}", ")", ";", "if", "(", "$", ".", "isFunction", "(", "$", ".", "fn", ".", "on", ")", ")", "{", "// For jQuery 1.7+", "$", "(", "document", ")", ".", "on", "(", "'click.'", "+", "prefix", ",", "'.'", "+", "boxElement", ",", "clickHandler", ")", ";", "}", "else", "{", "// For jQuery 1.3.x -> 1.6.x", "// This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed.", "// This is not here for jQuery 1.9, it's here for legacy users.", "$", "(", "'.'", "+", "boxElement", ")", ".", "live", "(", "'click.'", "+", "prefix", ",", "clickHandler", ")", ";", "}", "}", "return", "true", ";", "}", "return", "false", ";", "}" ]
Add Colorbox's event bindings
[ "Add", "Colorbox", "s", "event", "bindings" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/assets/js/uncompressed/jquery.colorbox.js#L457-L518
37,590
ToMMApps/express-waf
blocker.js
Blocker
function Blocker(config, logger) { //DB must define an add, remove and contains function! if(!(config.db && config.db.add && config.db.remove && config.db.contains)){ throw "db must define an add, remove and contains function"; }; _config = config; _logger = logger; }
javascript
function Blocker(config, logger) { //DB must define an add, remove and contains function! if(!(config.db && config.db.add && config.db.remove && config.db.contains)){ throw "db must define an add, remove and contains function"; }; _config = config; _logger = logger; }
[ "function", "Blocker", "(", "config", ",", "logger", ")", "{", "//DB must define an add, remove and contains function!", "if", "(", "!", "(", "config", ".", "db", "&&", "config", ".", "db", ".", "add", "&&", "config", ".", "db", ".", "remove", "&&", "config", ".", "db", ".", "contains", ")", ")", "{", "throw", "\"db must define an add, remove and contains function\"", ";", "}", ";", "_config", "=", "config", ";", "_logger", "=", "logger", ";", "}" ]
The Blocker class realizes an IP blocklist that allows other modules to block attackers. @param config must contain at least an object named db that must have an add, remove and contains function. Furthermore it allow the user to specifiy a blockTime. If blockTime is not set, entries will never be removed from Blocklist. @constructor
[ "The", "Blocker", "class", "realizes", "an", "IP", "blocklist", "that", "allows", "other", "modules", "to", "block", "attackers", "." ]
5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a
https://github.com/ToMMApps/express-waf/blob/5c2c3ec379722d3ee63b3bf8c5fe65d4a0c0bb6a/blocker.js#L13-L22
37,591
zhengxiaoyao0716/markplus
lib/Render.js
replaceHtml
function replaceHtml(ele, html) { var _this = this; if (ele.classList.contains('raw-text')) { return; } ele.innerHTML = withEscape( // eslint-disable-line no-undef function (html) { return function (reg, rep) { return _this.htmlSugars.reduce(function (html, _ref) { var _ref2 = _slicedToArray(_ref, 2), regExp = _ref2[0], replace = _ref2[1]; return html.replace(regExp, replace); }, html).replace(reg, rep); }; })(html); }
javascript
function replaceHtml(ele, html) { var _this = this; if (ele.classList.contains('raw-text')) { return; } ele.innerHTML = withEscape( // eslint-disable-line no-undef function (html) { return function (reg, rep) { return _this.htmlSugars.reduce(function (html, _ref) { var _ref2 = _slicedToArray(_ref, 2), regExp = _ref2[0], replace = _ref2[1]; return html.replace(regExp, replace); }, html).replace(reg, rep); }; })(html); }
[ "function", "replaceHtml", "(", "ele", ",", "html", ")", "{", "var", "_this", "=", "this", ";", "if", "(", "ele", ".", "classList", ".", "contains", "(", "'raw-text'", ")", ")", "{", "return", ";", "}", "ele", ".", "innerHTML", "=", "withEscape", "(", "// eslint-disable-line no-undef", "function", "(", "html", ")", "{", "return", "function", "(", "reg", ",", "rep", ")", "{", "return", "_this", ".", "htmlSugars", ".", "reduce", "(", "function", "(", "html", ",", "_ref", ")", "{", "var", "_ref2", "=", "_slicedToArray", "(", "_ref", ",", "2", ")", ",", "regExp", "=", "_ref2", "[", "0", "]", ",", "replace", "=", "_ref2", "[", "1", "]", ";", "return", "html", ".", "replace", "(", "regExp", ",", "replace", ")", ";", "}", ",", "html", ")", ".", "replace", "(", "reg", ",", "rep", ")", ";", "}", ";", "}", ")", "(", "html", ")", ";", "}" ]
replace the sugars in the html content. @param {HTMLElement} ele Element witch the resolved html will be set on. @param {*} html Html content to be replaced the sugars.
[ "replace", "the", "sugars", "in", "the", "html", "content", "." ]
fd55e04beb2025b483e78ae5fb711dcbf3083035
https://github.com/zhengxiaoyao0716/markplus/blob/fd55e04beb2025b483e78ae5fb711dcbf3083035/lib/Render.js#L73-L91
37,592
infrabel/themes-gnap
raw/angular-local-storage/angular-local-storage.js
function() { try { return navigator.cookieEnabled || ("cookie" in $document && ($document.cookie.length > 0 || ($document.cookie = "test").indexOf.call($document.cookie, "test") > -1)); } catch (e) { $rootScope.$broadcast('LocalStorageModule.notification.error', e.message); return false; } }
javascript
function() { try { return navigator.cookieEnabled || ("cookie" in $document && ($document.cookie.length > 0 || ($document.cookie = "test").indexOf.call($document.cookie, "test") > -1)); } catch (e) { $rootScope.$broadcast('LocalStorageModule.notification.error', e.message); return false; } }
[ "function", "(", ")", "{", "try", "{", "return", "navigator", ".", "cookieEnabled", "||", "(", "\"cookie\"", "in", "$document", "&&", "(", "$document", ".", "cookie", ".", "length", ">", "0", "||", "(", "$document", ".", "cookie", "=", "\"test\"", ")", ".", "indexOf", ".", "call", "(", "$document", ".", "cookie", ",", "\"test\"", ")", ">", "-", "1", ")", ")", ";", "}", "catch", "(", "e", ")", "{", "$rootScope", ".", "$broadcast", "(", "'LocalStorageModule.notification.error'", ",", "e", ".", "message", ")", ";", "return", "false", ";", "}", "}" ]
Checks the browser to see if cookies are supported
[ "Checks", "the", "browser", "to", "see", "if", "cookies", "are", "supported" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/angular-local-storage/angular-local-storage.js#L264-L273
37,593
infrabel/themes-gnap
raw/ace/mustache/app/views/assets/scripts/jqgrid.js
updatePagerIcons
function updatePagerIcons(table) { var replacement = { 'ui-icon-seek-first' : 'icon-double-angle-left bigger-140', 'ui-icon-seek-prev' : 'icon-angle-left bigger-140', 'ui-icon-seek-next' : 'icon-angle-right bigger-140', 'ui-icon-seek-end' : 'icon-double-angle-right bigger-140' }; $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){ var icon = $(this); var $class = $.trim(icon.attr('class').replace('ui-icon', '')); if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]); }) }
javascript
function updatePagerIcons(table) { var replacement = { 'ui-icon-seek-first' : 'icon-double-angle-left bigger-140', 'ui-icon-seek-prev' : 'icon-angle-left bigger-140', 'ui-icon-seek-next' : 'icon-angle-right bigger-140', 'ui-icon-seek-end' : 'icon-double-angle-right bigger-140' }; $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function(){ var icon = $(this); var $class = $.trim(icon.attr('class').replace('ui-icon', '')); if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]); }) }
[ "function", "updatePagerIcons", "(", "table", ")", "{", "var", "replacement", "=", "{", "'ui-icon-seek-first'", ":", "'icon-double-angle-left bigger-140'", ",", "'ui-icon-seek-prev'", ":", "'icon-angle-left bigger-140'", ",", "'ui-icon-seek-next'", ":", "'icon-angle-right bigger-140'", ",", "'ui-icon-seek-end'", ":", "'icon-double-angle-right bigger-140'", "}", ";", "$", "(", "'.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon'", ")", ".", "each", "(", "function", "(", ")", "{", "var", "icon", "=", "$", "(", "this", ")", ";", "var", "$class", "=", "$", ".", "trim", "(", "icon", ".", "attr", "(", "'class'", ")", ".", "replace", "(", "'ui-icon'", ",", "''", ")", ")", ";", "if", "(", "$class", "in", "replacement", ")", "icon", ".", "attr", "(", "'class'", ",", "'ui-icon '", "+", "replacement", "[", "$class", "]", ")", ";", "}", ")", "}" ]
replace icons with FontAwesome icons like above
[ "replace", "icons", "with", "FontAwesome", "icons", "like", "above" ]
9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9
https://github.com/infrabel/themes-gnap/blob/9ffd0026b3908b75b42a9fb95cd6b5c6fe1b13d9/raw/ace/mustache/app/views/assets/scripts/jqgrid.js#L285-L299
37,594
jimivdw/grunt-mutation-testing
lib/karma/KarmaServerManager.js
KarmaServerManager
function KarmaServerManager(config, port, runnerTimeUnlimited) { this._status = null; this._serverProcess = null; this._runnerTimeUnlimited = runnerTimeUnlimited; this._config = _.merge({ waitForServerTime: 10, waitForRunnerTime: 2 }, config, { port: port }); var notIncluded = this._config.notIncluded || []; this._config.files = _.map(this._config.files, function(filename) { return { pattern: filename, included: _.indexOf(notIncluded, filename) < 0 }; }); }
javascript
function KarmaServerManager(config, port, runnerTimeUnlimited) { this._status = null; this._serverProcess = null; this._runnerTimeUnlimited = runnerTimeUnlimited; this._config = _.merge({ waitForServerTime: 10, waitForRunnerTime: 2 }, config, { port: port }); var notIncluded = this._config.notIncluded || []; this._config.files = _.map(this._config.files, function(filename) { return { pattern: filename, included: _.indexOf(notIncluded, filename) < 0 }; }); }
[ "function", "KarmaServerManager", "(", "config", ",", "port", ",", "runnerTimeUnlimited", ")", "{", "this", ".", "_status", "=", "null", ";", "this", ".", "_serverProcess", "=", "null", ";", "this", ".", "_runnerTimeUnlimited", "=", "runnerTimeUnlimited", ";", "this", ".", "_config", "=", "_", ".", "merge", "(", "{", "waitForServerTime", ":", "10", ",", "waitForRunnerTime", ":", "2", "}", ",", "config", ",", "{", "port", ":", "port", "}", ")", ";", "var", "notIncluded", "=", "this", ".", "_config", ".", "notIncluded", "||", "[", "]", ";", "this", ".", "_config", ".", "files", "=", "_", ".", "map", "(", "this", ".", "_config", ".", "files", ",", "function", "(", "filename", ")", "{", "return", "{", "pattern", ":", "filename", ",", "included", ":", "_", ".", "indexOf", "(", "notIncluded", ",", "filename", ")", "<", "0", "}", ";", "}", ")", ";", "}" ]
Constructor for a Karma server instance @param config {object} Karma configuration object that should be used @param port {number} The port on which the Karma server should run @param runnerTimeUnlimited {boolean} if set the KarmaServerManager will not limit the running time of the runner @constructor
[ "Constructor", "for", "a", "Karma", "server", "instance" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/karma/KarmaServerManager.js#L30-L40
37,595
jimivdw/grunt-mutation-testing
lib/karma/KarmaServerManager.js
startServer
function startServer(serverPromise) { var self = this, startTime = Date.now(), browsersStarting, serverTimeout, serverProcess = fork(__dirname + '/KarmaWorker.js', { silent: true }); // Limit the time it can take for a server to start to config.waitForServerTime seconds serverTimeout = setTimeout(function() { self._setStatus(KarmaServerStatus.DEFUNCT); serverPromise.reject( 'Could not connect to a Karma server on port ' + self._config.port + ' within ' + self._config.waitForServerTime + ' seconds' ); }, self._config.waitForServerTime * 1000); serverProcess.send({ command: 'start', config: self._config }); serverProcess.stdout.on('data', function(data) { var message = data.toString('utf-8'), messageParts = message.split(/\s/g); logger.debug(message); //this is a hack: because Karma exposes no method of determining when the server is started up we'll dissect the log messages if(message.indexOf('Starting browser') > -1) { browsersStarting = browsersStarting ? browsersStarting.concat([messageParts[4]]) : [messageParts[4]]; } if(message.indexOf('Connected on socket') > -1) { browsersStarting.pop(); if(browsersStarting && browsersStarting.length === 0) { clearTimeout(serverTimeout); self._setStatus(KarmaServerStatus.READY); logger.info( 'Karma server started after %dms and is listening on port %d', (Date.now() - startTime), self._config.port ); serverPromise.resolve(self); } } }); return serverProcess; }
javascript
function startServer(serverPromise) { var self = this, startTime = Date.now(), browsersStarting, serverTimeout, serverProcess = fork(__dirname + '/KarmaWorker.js', { silent: true }); // Limit the time it can take for a server to start to config.waitForServerTime seconds serverTimeout = setTimeout(function() { self._setStatus(KarmaServerStatus.DEFUNCT); serverPromise.reject( 'Could not connect to a Karma server on port ' + self._config.port + ' within ' + self._config.waitForServerTime + ' seconds' ); }, self._config.waitForServerTime * 1000); serverProcess.send({ command: 'start', config: self._config }); serverProcess.stdout.on('data', function(data) { var message = data.toString('utf-8'), messageParts = message.split(/\s/g); logger.debug(message); //this is a hack: because Karma exposes no method of determining when the server is started up we'll dissect the log messages if(message.indexOf('Starting browser') > -1) { browsersStarting = browsersStarting ? browsersStarting.concat([messageParts[4]]) : [messageParts[4]]; } if(message.indexOf('Connected on socket') > -1) { browsersStarting.pop(); if(browsersStarting && browsersStarting.length === 0) { clearTimeout(serverTimeout); self._setStatus(KarmaServerStatus.READY); logger.info( 'Karma server started after %dms and is listening on port %d', (Date.now() - startTime), self._config.port ); serverPromise.resolve(self); } } }); return serverProcess; }
[ "function", "startServer", "(", "serverPromise", ")", "{", "var", "self", "=", "this", ",", "startTime", "=", "Date", ".", "now", "(", ")", ",", "browsersStarting", ",", "serverTimeout", ",", "serverProcess", "=", "fork", "(", "__dirname", "+", "'/KarmaWorker.js'", ",", "{", "silent", ":", "true", "}", ")", ";", "// Limit the time it can take for a server to start to config.waitForServerTime seconds", "serverTimeout", "=", "setTimeout", "(", "function", "(", ")", "{", "self", ".", "_setStatus", "(", "KarmaServerStatus", ".", "DEFUNCT", ")", ";", "serverPromise", ".", "reject", "(", "'Could not connect to a Karma server on port '", "+", "self", ".", "_config", ".", "port", "+", "' within '", "+", "self", ".", "_config", ".", "waitForServerTime", "+", "' seconds'", ")", ";", "}", ",", "self", ".", "_config", ".", "waitForServerTime", "*", "1000", ")", ";", "serverProcess", ".", "send", "(", "{", "command", ":", "'start'", ",", "config", ":", "self", ".", "_config", "}", ")", ";", "serverProcess", ".", "stdout", ".", "on", "(", "'data'", ",", "function", "(", "data", ")", "{", "var", "message", "=", "data", ".", "toString", "(", "'utf-8'", ")", ",", "messageParts", "=", "message", ".", "split", "(", "/", "\\s", "/", "g", ")", ";", "logger", ".", "debug", "(", "message", ")", ";", "//this is a hack: because Karma exposes no method of determining when the server is started up we'll dissect the log messages", "if", "(", "message", ".", "indexOf", "(", "'Starting browser'", ")", ">", "-", "1", ")", "{", "browsersStarting", "=", "browsersStarting", "?", "browsersStarting", ".", "concat", "(", "[", "messageParts", "[", "4", "]", "]", ")", ":", "[", "messageParts", "[", "4", "]", "]", ";", "}", "if", "(", "message", ".", "indexOf", "(", "'Connected on socket'", ")", ">", "-", "1", ")", "{", "browsersStarting", ".", "pop", "(", ")", ";", "if", "(", "browsersStarting", "&&", "browsersStarting", ".", "length", "===", "0", ")", "{", "clearTimeout", "(", "serverTimeout", ")", ";", "self", ".", "_setStatus", "(", "KarmaServerStatus", ".", "READY", ")", ";", "logger", ".", "info", "(", "'Karma server started after %dms and is listening on port %d'", ",", "(", "Date", ".", "now", "(", ")", "-", "startTime", ")", ",", "self", ".", "_config", ".", "port", ")", ";", "serverPromise", ".", "resolve", "(", "self", ")", ";", "}", "}", "}", ")", ";", "return", "serverProcess", ";", "}" ]
start a karma server by calling node's "fork" method. The stdio will be piped to the current process so that it can be read and interpreted
[ "start", "a", "karma", "server", "by", "calling", "node", "s", "fork", "method", ".", "The", "stdio", "will", "be", "piped", "to", "the", "current", "process", "so", "that", "it", "can", "be", "read", "and", "interpreted" ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/lib/karma/KarmaServerManager.js#L165-L210
37,596
jimivdw/grunt-mutation-testing
utils/ExclusionUtils.js
parseASTComments
function parseASTComments(astNode) { var comments = []; if(astNode && astNode.leadingComments) { _.forEach(astNode.leadingComments, function(comment) { if(comment.type === 'Block') { comments = comments.concat(comment.value.split('\n').map(function(commentLine) { // Remove asterisks at the start of the line return commentLine.replace(/^\s*\*\s*/g, '').trim(); })); } else { comments.push(comment.value); } }); } return comments; }
javascript
function parseASTComments(astNode) { var comments = []; if(astNode && astNode.leadingComments) { _.forEach(astNode.leadingComments, function(comment) { if(comment.type === 'Block') { comments = comments.concat(comment.value.split('\n').map(function(commentLine) { // Remove asterisks at the start of the line return commentLine.replace(/^\s*\*\s*/g, '').trim(); })); } else { comments.push(comment.value); } }); } return comments; }
[ "function", "parseASTComments", "(", "astNode", ")", "{", "var", "comments", "=", "[", "]", ";", "if", "(", "astNode", "&&", "astNode", ".", "leadingComments", ")", "{", "_", ".", "forEach", "(", "astNode", ".", "leadingComments", ",", "function", "(", "comment", ")", "{", "if", "(", "comment", ".", "type", "===", "'Block'", ")", "{", "comments", "=", "comments", ".", "concat", "(", "comment", ".", "value", ".", "split", "(", "'\\n'", ")", ".", "map", "(", "function", "(", "commentLine", ")", "{", "// Remove asterisks at the start of the line", "return", "commentLine", ".", "replace", "(", "/", "^\\s*\\*\\s*", "/", "g", ",", "''", ")", ".", "trim", "(", ")", ";", "}", ")", ")", ";", "}", "else", "{", "comments", ".", "push", "(", "comment", ".", "value", ")", ";", "}", "}", ")", ";", "}", "return", "comments", ";", "}" ]
Parse the comments from a given astNode. It removes all leading asterisks from multiline comments, as well as all leading and trailing whitespace. @param {object} astNode the AST node from which comments should be retrieved @returns {[string]} the comments for the AST node, or an empty array if none could be found
[ "Parse", "the", "comments", "from", "a", "given", "astNode", ".", "It", "removes", "all", "leading", "asterisks", "from", "multiline", "comments", "as", "well", "as", "all", "leading", "and", "trailing", "whitespace", "." ]
698b1b20813cd7d46cf44f09cc016f5cd6460f5f
https://github.com/jimivdw/grunt-mutation-testing/blob/698b1b20813cd7d46cf44f09cc016f5cd6460f5f/utils/ExclusionUtils.js#L22-L38
37,597
joshfire/woodman
precompile/precompile.js
function (node, nodeType) { var parentNode = node; var levelNode = 0; // Security in while loop while ((parentNode.type !== nodeType) && (parentNode.parent !== undefined) && (levelNode <= 20)) { levelNode++; parentNode = parentNode.parent; } parentNode.levelNode = levelNode; return parentNode; }
javascript
function (node, nodeType) { var parentNode = node; var levelNode = 0; // Security in while loop while ((parentNode.type !== nodeType) && (parentNode.parent !== undefined) && (levelNode <= 20)) { levelNode++; parentNode = parentNode.parent; } parentNode.levelNode = levelNode; return parentNode; }
[ "function", "(", "node", ",", "nodeType", ")", "{", "var", "parentNode", "=", "node", ";", "var", "levelNode", "=", "0", ";", "// Security in while loop", "while", "(", "(", "parentNode", ".", "type", "!==", "nodeType", ")", "&&", "(", "parentNode", ".", "parent", "!==", "undefined", ")", "&&", "(", "levelNode", "<=", "20", ")", ")", "{", "levelNode", "++", ";", "parentNode", "=", "parentNode", ".", "parent", ";", "}", "parentNode", ".", "levelNode", "=", "levelNode", ";", "return", "parentNode", ";", "}" ]
Returns the first ancestor of the given node in the AST tree that has the specified node type. @function @param {Object} node The node to start from in the AST tree @param {string} nodeType The type of node you are searching for, e.g. "VariableDeclaration", "ExpressionStatement"... @return {Object} The first node in the ancestors of the given node that matches the given type, null if not found
[ "Returns", "the", "first", "ancestor", "of", "the", "given", "node", "in", "the", "AST", "tree", "that", "has", "the", "specified", "node", "type", "." ]
fdc05de2124388780924980e6f27bf4483056d18
https://github.com/joshfire/woodman/blob/fdc05de2124388780924980e6f27bf4483056d18/precompile/precompile.js#L124-L135
37,598
peerigon/alamid-schema
plugins/validation/index.js
runValidation
function runValidation(validators, field, context, callback) { var fieldErrors = []; var pending = 0; function saveResult(result) { if (result !== true) { fieldErrors.push(result); } } function doCallback() { callback(fieldErrors); } function asyncValidationDone(result) { saveResult(result); pending--; pending === 0 && doCallback(); } validators.forEach(function (validator) { if (validator.length === 2) { pending++; validator.call(context, field, asyncValidationDone); } else { saveResult(validator.call(context, field)); } }); if (pending === 0) { // synchronous callback doCallback(); } return fieldErrors; }
javascript
function runValidation(validators, field, context, callback) { var fieldErrors = []; var pending = 0; function saveResult(result) { if (result !== true) { fieldErrors.push(result); } } function doCallback() { callback(fieldErrors); } function asyncValidationDone(result) { saveResult(result); pending--; pending === 0 && doCallback(); } validators.forEach(function (validator) { if (validator.length === 2) { pending++; validator.call(context, field, asyncValidationDone); } else { saveResult(validator.call(context, field)); } }); if (pending === 0) { // synchronous callback doCallback(); } return fieldErrors; }
[ "function", "runValidation", "(", "validators", ",", "field", ",", "context", ",", "callback", ")", "{", "var", "fieldErrors", "=", "[", "]", ";", "var", "pending", "=", "0", ";", "function", "saveResult", "(", "result", ")", "{", "if", "(", "result", "!==", "true", ")", "{", "fieldErrors", ".", "push", "(", "result", ")", ";", "}", "}", "function", "doCallback", "(", ")", "{", "callback", "(", "fieldErrors", ")", ";", "}", "function", "asyncValidationDone", "(", "result", ")", "{", "saveResult", "(", "result", ")", ";", "pending", "--", ";", "pending", "===", "0", "&&", "doCallback", "(", ")", ";", "}", "validators", ".", "forEach", "(", "function", "(", "validator", ")", "{", "if", "(", "validator", ".", "length", "===", "2", ")", "{", "pending", "++", ";", "validator", ".", "call", "(", "context", ",", "field", ",", "asyncValidationDone", ")", ";", "}", "else", "{", "saveResult", "(", "validator", ".", "call", "(", "context", ",", "field", ")", ")", ";", "}", "}", ")", ";", "if", "(", "pending", "===", "0", ")", "{", "// synchronous callback", "doCallback", "(", ")", ";", "}", "return", "fieldErrors", ";", "}" ]
Runs the given validators on a single field. Caution: callback will be called in synchronously in some situations. This behavior should usually be avoided in public APIs, but since runValidation() is internal, we know how to deal with it. It allows us to speed up validation and to return all synchronous validation results as soon as possible. The final callback, however, is guaranteed to be asynchronous. @param {Array} validators @param {*} field @param {Object} context @param {Function} callback @returns {Array}
[ "Runs", "the", "given", "validators", "on", "a", "single", "field", "." ]
7faa6e826f485b33ccc2e41b86b5861c61184a3c
https://github.com/peerigon/alamid-schema/blob/7faa6e826f485b33ccc2e41b86b5861c61184a3c/plugins/validation/index.js#L21-L56
37,599
peerigon/alamid-schema
plugins/validation/validators.js
matchesValidator
function matchesValidator(match) { return function matchValue(value) { var result; if (typeof match.test === "function") { match.lastIndex = 0; // reset the lastIndex just in case the regexp is accidentally global result = match.test(value); } else { result = match === value; } return result || "matches"; }; }
javascript
function matchesValidator(match) { return function matchValue(value) { var result; if (typeof match.test === "function") { match.lastIndex = 0; // reset the lastIndex just in case the regexp is accidentally global result = match.test(value); } else { result = match === value; } return result || "matches"; }; }
[ "function", "matchesValidator", "(", "match", ")", "{", "return", "function", "matchValue", "(", "value", ")", "{", "var", "result", ";", "if", "(", "typeof", "match", ".", "test", "===", "\"function\"", ")", "{", "match", ".", "lastIndex", "=", "0", ";", "// reset the lastIndex just in case the regexp is accidentally global", "result", "=", "match", ".", "test", "(", "value", ")", ";", "}", "else", "{", "result", "=", "match", "===", "value", ";", "}", "return", "result", "||", "\"matches\"", ";", "}", ";", "}" ]
Returns true if the given value matches the pattern. The pattern may be a value or a regular expression. If it's a value, a strict comparison will be performed. In case it's a regex, the test method will be invoked. @param {*|RegExp} match @returns {Function}
[ "Returns", "true", "if", "the", "given", "value", "matches", "the", "pattern", ".", "The", "pattern", "may", "be", "a", "value", "or", "a", "regular", "expression", ".", "If", "it", "s", "a", "value", "a", "strict", "comparison", "will", "be", "performed", ".", "In", "case", "it", "s", "a", "regex", "the", "test", "method", "will", "be", "invoked", "." ]
7faa6e826f485b33ccc2e41b86b5861c61184a3c
https://github.com/peerigon/alamid-schema/blob/7faa6e826f485b33ccc2e41b86b5861c61184a3c/plugins/validation/validators.js#L94-L107