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
14,800
bhushankumarl/amazon-mws
lib/amazon-mws.js
function (cb) { if (AmazonMws.USER_AGENT_SERIALIZED) { return cb(AmazonMws.USER_AGENT_SERIALIZED); } this.getClientUserAgentSeeded(AmazonMws.USER_AGENT, function (cua) { AmazonMws.USER_AGENT_SERIALIZED = cua; cb(AmazonMws.USER_AGENT_SERIALIZED); }); }
javascript
function (cb) { if (AmazonMws.USER_AGENT_SERIALIZED) { return cb(AmazonMws.USER_AGENT_SERIALIZED); } this.getClientUserAgentSeeded(AmazonMws.USER_AGENT, function (cua) { AmazonMws.USER_AGENT_SERIALIZED = cua; cb(AmazonMws.USER_AGENT_SERIALIZED); }); }
[ "function", "(", "cb", ")", "{", "if", "(", "AmazonMws", ".", "USER_AGENT_SERIALIZED", ")", "{", "return", "cb", "(", "AmazonMws", ".", "USER_AGENT_SERIALIZED", ")", ";", "}", "this", ".", "getClientUserAgentSeeded", "(", "AmazonMws", ".", "USER_AGENT", ",", ...
Gets a JSON version of a User-Agent and uses a cached version for a slight speed advantage.
[ "Gets", "a", "JSON", "version", "of", "a", "User", "-", "Agent", "and", "uses", "a", "cached", "version", "for", "a", "slight", "speed", "advantage", "." ]
e531635363a03a124c75bfac7aedde89b1193d07
https://github.com/bhushankumarl/amazon-mws/blob/e531635363a03a124c75bfac7aedde89b1193d07/lib/amazon-mws.js#L153-L161
14,801
bhushankumarl/amazon-mws
lib/amazon-mws.js
function (seed, cb) { exec('uname -a', function (err, uname) { var userAgent = {}; for (var field in seed) { userAgent[field] = encodeURIComponent(seed[field]); } // URI-encode in case there are unusual characters in the system's uname. userAgent.uname = encodeURIComponent(uname) || 'UNKNOWN'; cb(JSON.stringify(userAgent)); }); }
javascript
function (seed, cb) { exec('uname -a', function (err, uname) { var userAgent = {}; for (var field in seed) { userAgent[field] = encodeURIComponent(seed[field]); } // URI-encode in case there are unusual characters in the system's uname. userAgent.uname = encodeURIComponent(uname) || 'UNKNOWN'; cb(JSON.stringify(userAgent)); }); }
[ "function", "(", "seed", ",", "cb", ")", "{", "exec", "(", "'uname -a'", ",", "function", "(", "err", ",", "uname", ")", "{", "var", "userAgent", "=", "{", "}", ";", "for", "(", "var", "field", "in", "seed", ")", "{", "userAgent", "[", "field", "...
Gets a JSON version of a User-Agent by encoding a seeded object and fetching a uname from the system.
[ "Gets", "a", "JSON", "version", "of", "a", "User", "-", "Agent", "by", "encoding", "a", "seeded", "object", "and", "fetching", "a", "uname", "from", "the", "system", "." ]
e531635363a03a124c75bfac7aedde89b1193d07
https://github.com/bhushankumarl/amazon-mws/blob/e531635363a03a124c75bfac7aedde89b1193d07/lib/amazon-mws.js#L165-L177
14,802
weyoss/redis-smq
src/gc.js
collectMessage
function collectMessage(message, processingQueue, cb) { const threshold = message.getRetryThreshold(); const messageRetryThreshold = typeof threshold === 'number' ? threshold : dispatcher.getMessageRetryThreshold(); const delay = message.getRetryDelay(); const messageRetryDelay = typeof delay === 'number' ? delay : dispatcher.getMessageRetryDelay(); let destQueueName = null; let delayed = false; let requeued = false; const multi = client.multi(); /** * Only exceptions from non periodic messages are handled. * Periodic messages are ignored once they are delivered to a consumer. */ if (!dispatcher.isPeriodic(message)) { const uuid = message.getId(); /** * Attempts */ const attempts = increaseAttempts(message); /** * */ if (attempts < messageRetryThreshold) { debug(`Trying to consume message ID [${uuid}] again (attempts: [${attempts}]) ...`); if (messageRetryDelay) { debug(`Scheduling message ID [${uuid}] (delay: [${messageRetryDelay}])...`); message.setScheduledDelay(messageRetryDelay); dispatcher.schedule(message, multi); delayed = true; } else { debug(`Message ID [${uuid}] is going to be enqueued immediately...`); destQueueName = keyQueueName; requeued = true; } } else { debug(`Message ID [${uuid}] has exceeded max retry threshold...`); destQueueName = keyQueueNameDead; } /** * */ if (destQueueName) { debug(`Moving message [${uuid}] to queue [${destQueueName}]...`); multi.lpush(destQueueName, message.toString()); } multi.rpop(processingQueue); multi.exec((err) => { if (err) cb(err); else { if (dispatcher.isTest()) { if (requeued) dispatcher.emit(events.MESSAGE_REQUEUED, message); else if (delayed) dispatcher.emit(events.MESSAGE_DELAYED, message); else dispatcher.emit(events.MESSAGE_DEAD_LETTER, message); } cb(); } }); } else { client.rpop(processingQueue, cb); } }
javascript
function collectMessage(message, processingQueue, cb) { const threshold = message.getRetryThreshold(); const messageRetryThreshold = typeof threshold === 'number' ? threshold : dispatcher.getMessageRetryThreshold(); const delay = message.getRetryDelay(); const messageRetryDelay = typeof delay === 'number' ? delay : dispatcher.getMessageRetryDelay(); let destQueueName = null; let delayed = false; let requeued = false; const multi = client.multi(); /** * Only exceptions from non periodic messages are handled. * Periodic messages are ignored once they are delivered to a consumer. */ if (!dispatcher.isPeriodic(message)) { const uuid = message.getId(); /** * Attempts */ const attempts = increaseAttempts(message); /** * */ if (attempts < messageRetryThreshold) { debug(`Trying to consume message ID [${uuid}] again (attempts: [${attempts}]) ...`); if (messageRetryDelay) { debug(`Scheduling message ID [${uuid}] (delay: [${messageRetryDelay}])...`); message.setScheduledDelay(messageRetryDelay); dispatcher.schedule(message, multi); delayed = true; } else { debug(`Message ID [${uuid}] is going to be enqueued immediately...`); destQueueName = keyQueueName; requeued = true; } } else { debug(`Message ID [${uuid}] has exceeded max retry threshold...`); destQueueName = keyQueueNameDead; } /** * */ if (destQueueName) { debug(`Moving message [${uuid}] to queue [${destQueueName}]...`); multi.lpush(destQueueName, message.toString()); } multi.rpop(processingQueue); multi.exec((err) => { if (err) cb(err); else { if (dispatcher.isTest()) { if (requeued) dispatcher.emit(events.MESSAGE_REQUEUED, message); else if (delayed) dispatcher.emit(events.MESSAGE_DELAYED, message); else dispatcher.emit(events.MESSAGE_DEAD_LETTER, message); } cb(); } }); } else { client.rpop(processingQueue, cb); } }
[ "function", "collectMessage", "(", "message", ",", "processingQueue", ",", "cb", ")", "{", "const", "threshold", "=", "message", ".", "getRetryThreshold", "(", ")", ";", "const", "messageRetryThreshold", "=", "typeof", "threshold", "===", "'number'", "?", "thres...
Move message to dead-letter queue when max attempts threshold is reached otherwise requeue it again @param {object} message @param {string} processingQueue @param {function} cb
[ "Move", "message", "to", "dead", "-", "letter", "queue", "when", "max", "attempts", "threshold", "is", "reached", "otherwise", "requeue", "it", "again" ]
1744d8a6bb262e73dcc1efe46bf0575fbb5a32ee
https://github.com/weyoss/redis-smq/blob/1744d8a6bb262e73dcc1efe46bf0575fbb5a32ee/src/gc.js#L147-L214
14,803
nolanlawson/optimize-js
lib/index.js
isPaddedArgument
function isPaddedArgument (node) { var parentArray = node.parent().arguments ? node.parent().arguments : node.parent().elements var idx = parentArray.indexOf(node) if (idx === 0) { // first arg if (prePreChar === '(' && preChar === '(' && postChar === ')') { // already padded return true } } else if (idx === parentArray.length - 1) { // last arg if (preChar === '(' && postChar === ')' && postPostChar === ')') { // already padded return true } } else { // middle arg if (preChar === '(' && postChar === ')') { // already padded return true } } return false }
javascript
function isPaddedArgument (node) { var parentArray = node.parent().arguments ? node.parent().arguments : node.parent().elements var idx = parentArray.indexOf(node) if (idx === 0) { // first arg if (prePreChar === '(' && preChar === '(' && postChar === ')') { // already padded return true } } else if (idx === parentArray.length - 1) { // last arg if (preChar === '(' && postChar === ')' && postPostChar === ')') { // already padded return true } } else { // middle arg if (preChar === '(' && postChar === ')') { // already padded return true } } return false }
[ "function", "isPaddedArgument", "(", "node", ")", "{", "var", "parentArray", "=", "node", ".", "parent", "(", ")", ".", "arguments", "?", "node", ".", "parent", "(", ")", ".", "arguments", ":", "node", ".", "parent", "(", ")", ".", "elements", "var", ...
assuming this node is an argument to a function or an element in an array, return true if it itself is already padded with parentheses
[ "assuming", "this", "node", "is", "an", "argument", "to", "a", "function", "or", "an", "element", "in", "an", "array", "return", "true", "if", "it", "itself", "is", "already", "padded", "with", "parentheses" ]
7bc083cd0b93961ab2d63cddbacceb1689817a31
https://github.com/nolanlawson/optimize-js/blob/7bc083cd0b93961ab2d63cddbacceb1689817a31/lib/index.js#L25-L42
14,804
nolanlawson/optimize-js
lib/index.js
isArgumentToFunctionCall
function isArgumentToFunctionCall (node) { return isCallExpression(node.parent()) && node.parent().arguments.length && node.parent().arguments.indexOf(node) !== -1 }
javascript
function isArgumentToFunctionCall (node) { return isCallExpression(node.parent()) && node.parent().arguments.length && node.parent().arguments.indexOf(node) !== -1 }
[ "function", "isArgumentToFunctionCall", "(", "node", ")", "{", "return", "isCallExpression", "(", "node", ".", "parent", "(", ")", ")", "&&", "node", ".", "parent", "(", ")", ".", "arguments", ".", "length", "&&", "node", ".", "parent", "(", ")", ".", ...
returns true iff node is an argument to a function call expression.
[ "returns", "true", "iff", "node", "is", "an", "argument", "to", "a", "function", "call", "expression", "." ]
7bc083cd0b93961ab2d63cddbacceb1689817a31
https://github.com/nolanlawson/optimize-js/blob/7bc083cd0b93961ab2d63cddbacceb1689817a31/lib/index.js#L62-L66
14,805
nolanlawson/optimize-js
lib/index.js
isIIFECall
function isIIFECall (node) { return node && isCallExpression(node) && node.callee && node.callee.type === 'FunctionExpression' }
javascript
function isIIFECall (node) { return node && isCallExpression(node) && node.callee && node.callee.type === 'FunctionExpression' }
[ "function", "isIIFECall", "(", "node", ")", "{", "return", "node", "&&", "isCallExpression", "(", "node", ")", "&&", "node", ".", "callee", "&&", "node", ".", "callee", ".", "type", "===", "'FunctionExpression'", "}" ]
returns true iff this is an IIFE call expression
[ "returns", "true", "iff", "this", "is", "an", "IIFE", "call", "expression" ]
7bc083cd0b93961ab2d63cddbacceb1689817a31
https://github.com/nolanlawson/optimize-js/blob/7bc083cd0b93961ab2d63cddbacceb1689817a31/lib/index.js#L90-L95
14,806
nolanlawson/optimize-js
lib/index.js
isProbablyWebpackModule
function isProbablyWebpackModule (node) { return isElementOfArray(node) && isArgumentToFunctionCall(node.parent()) && isIIFECall(node.parent().parent()) }
javascript
function isProbablyWebpackModule (node) { return isElementOfArray(node) && isArgumentToFunctionCall(node.parent()) && isIIFECall(node.parent().parent()) }
[ "function", "isProbablyWebpackModule", "(", "node", ")", "{", "return", "isElementOfArray", "(", "node", ")", "&&", "isArgumentToFunctionCall", "(", "node", ".", "parent", "(", ")", ")", "&&", "isIIFECall", "(", "node", ".", "parent", "(", ")", ".", "parent"...
tries to divine if this function is a webpack module wrapper. returns true iff node is an element of an array literal which is in turn an argument to a function call expression, and that function call expression is an IIFE.
[ "tries", "to", "divine", "if", "this", "function", "is", "a", "webpack", "module", "wrapper", ".", "returns", "true", "iff", "node", "is", "an", "element", "of", "an", "array", "literal", "which", "is", "in", "turn", "an", "argument", "to", "a", "functio...
7bc083cd0b93961ab2d63cddbacceb1689817a31
https://github.com/nolanlawson/optimize-js/blob/7bc083cd0b93961ab2d63cddbacceb1689817a31/lib/index.js#L101-L105
14,807
svgdotjs/svgdom
class/Node.js
arrayToMatrix
function arrayToMatrix (a) { return { a: a[0], b: a[1], c: a[2], d: a[3], e: a[4], f: a[5] } }
javascript
function arrayToMatrix (a) { return { a: a[0], b: a[1], c: a[2], d: a[3], e: a[4], f: a[5] } }
[ "function", "arrayToMatrix", "(", "a", ")", "{", "return", "{", "a", ":", "a", "[", "0", "]", ",", "b", ":", "a", "[", "1", "]", ",", "c", ":", "a", "[", "2", "]", ",", "d", ":", "a", "[", "3", "]", ",", "e", ":", "a", "[", "4", "]", ...
Map matrix array to object
[ "Map", "matrix", "array", "to", "object" ]
9b29c9e3e1c66577f8a546f1ee0f177a5fa0c222
https://github.com/svgdotjs/svgdom/blob/9b29c9e3e1c66577f8a546f1ee0f177a5fa0c222/class/Node.js#L21-L23
14,808
odysseyscience/react-s3-uploader
s3router.js
tempRedirect
function tempRedirect(req, res) { var params = { Bucket: S3_BUCKET, Key: checkTrailingSlash(getFileKeyDir(req)) + req.params[0] }; var s3 = getS3(); s3.getSignedUrl('getObject', params, function(err, url) { res.redirect(url); }); }
javascript
function tempRedirect(req, res) { var params = { Bucket: S3_BUCKET, Key: checkTrailingSlash(getFileKeyDir(req)) + req.params[0] }; var s3 = getS3(); s3.getSignedUrl('getObject', params, function(err, url) { res.redirect(url); }); }
[ "function", "tempRedirect", "(", "req", ",", "res", ")", "{", "var", "params", "=", "{", "Bucket", ":", "S3_BUCKET", ",", "Key", ":", "checkTrailingSlash", "(", "getFileKeyDir", "(", "req", ")", ")", "+", "req", ".", "params", "[", "0", "]", "}", ";"...
Redirects image requests with a temporary signed URL, giving access to GET an upload.
[ "Redirects", "image", "requests", "with", "a", "temporary", "signed", "URL", "giving", "access", "to", "GET", "an", "upload", "." ]
e372cf55c28fd3cfc15e74d2c622d89a3ad9ca7e
https://github.com/odysseyscience/react-s3-uploader/blob/e372cf55c28fd3cfc15e74d2c622d89a3ad9ca7e/s3router.js#L51-L60
14,809
hyperledger/fabric-chaincode-node
fabric-shim/lib/stub.js
createQueryMetadata
function createQueryMetadata (pageSize, bookmark) { const metadata = new _serviceProto.QueryMetadata(); metadata.setPageSize(pageSize); metadata.setBookmark(bookmark); return metadata.toBuffer(); }
javascript
function createQueryMetadata (pageSize, bookmark) { const metadata = new _serviceProto.QueryMetadata(); metadata.setPageSize(pageSize); metadata.setBookmark(bookmark); return metadata.toBuffer(); }
[ "function", "createQueryMetadata", "(", "pageSize", ",", "bookmark", ")", "{", "const", "metadata", "=", "new", "_serviceProto", ".", "QueryMetadata", "(", ")", ";", "metadata", ".", "setPageSize", "(", "pageSize", ")", ";", "metadata", ".", "setBookmark", "("...
Construct the QueryMetadata with a page size and a bookmark needed for pagination
[ "Construct", "the", "QueryMetadata", "with", "a", "page", "size", "and", "a", "bookmark", "needed", "for", "pagination" ]
6112a841c8b76ae8c627b8a68cf4318a6031bb8d
https://github.com/hyperledger/fabric-chaincode-node/blob/6112a841c8b76ae8c627b8a68cf4318a6031bb8d/fabric-shim/lib/stub.js#L103-L108
14,810
hyperledger/fabric-chaincode-node
build/npm.js
function (cwd = process.cwd()) { const promise = new Promise((resolve, reject) => { const _name = this.toString(); // eslint-disable-next-line no-console console.log(`spawning:: ${_name}`); const call = spawn(this.cmd, this.args, {env: process.env, shell: true, stdio: 'inherit', cwd}); this.args = []; call.on('exit', (code) => { // eslint-disable-next-line no-console console.log(`spawning:: ${_name} code::${code}`); if (code === 0) { resolve(0); } else { reject(code); } }); return call; }); return promise; }
javascript
function (cwd = process.cwd()) { const promise = new Promise((resolve, reject) => { const _name = this.toString(); // eslint-disable-next-line no-console console.log(`spawning:: ${_name}`); const call = spawn(this.cmd, this.args, {env: process.env, shell: true, stdio: 'inherit', cwd}); this.args = []; call.on('exit', (code) => { // eslint-disable-next-line no-console console.log(`spawning:: ${_name} code::${code}`); if (code === 0) { resolve(0); } else { reject(code); } }); return call; }); return promise; }
[ "function", "(", "cwd", "=", "process", ".", "cwd", "(", ")", ")", "{", "const", "promise", "=", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "const", "_name", "=", "this", ".", "toString", "(", ")", ";", "// eslint-disable-n...
can override the cwd
[ "can", "override", "the", "cwd" ]
6112a841c8b76ae8c627b8a68cf4318a6031bb8d
https://github.com/hyperledger/fabric-chaincode-node/blob/6112a841c8b76ae8c627b8a68cf4318a6031bb8d/build/npm.js#L38-L58
14,811
MeilleursAgents/react-mapbox-wrapper
src/Helpers/index.js
parseCoordinates
function parseCoordinates(coord) { if (Array.isArray(coord) && coord.length === 2) { return { lng: coord[0], lat: coord[1], }; } if (coord instanceof Object && coord !== null) { return { lng: coord.lng || coord.lon, lat: coord.lat, }; } return {}; }
javascript
function parseCoordinates(coord) { if (Array.isArray(coord) && coord.length === 2) { return { lng: coord[0], lat: coord[1], }; } if (coord instanceof Object && coord !== null) { return { lng: coord.lng || coord.lon, lat: coord.lat, }; } return {}; }
[ "function", "parseCoordinates", "(", "coord", ")", "{", "if", "(", "Array", ".", "isArray", "(", "coord", ")", "&&", "coord", ".", "length", "===", "2", ")", "{", "return", "{", "lng", ":", "coord", "[", "0", "]", ",", "lat", ":", "coord", "[", "...
Parse given argument as a coordinates @param {Any} coord Value representing a LngLatLike @return {Object} A comparable coordinates
[ "Parse", "given", "argument", "as", "a", "coordinates" ]
6f1cf3e8ecfc72a417cbc4963166b13a38eb30a3
https://github.com/MeilleursAgents/react-mapbox-wrapper/blob/6f1cf3e8ecfc72a417cbc4963166b13a38eb30a3/src/Helpers/index.js#L71-L87
14,812
humangeo/leaflet-dvf
examples/lib/timeline/timeline.js
function (object) { var listeners = this.listeners; for (var i = 0, iMax = this.listeners.length; i < iMax; i++) { var listener = listeners[i]; if (listener && listener.object == object) { return i; } } return -1; }
javascript
function (object) { var listeners = this.listeners; for (var i = 0, iMax = this.listeners.length; i < iMax; i++) { var listener = listeners[i]; if (listener && listener.object == object) { return i; } } return -1; }
[ "function", "(", "object", ")", "{", "var", "listeners", "=", "this", ".", "listeners", ";", "for", "(", "var", "i", "=", "0", ",", "iMax", "=", "this", ".", "listeners", ".", "length", ";", "i", "<", "iMax", ";", "i", "++", ")", "{", "var", "l...
Find a single listener by its object @param {Object} object @return {Number} index -1 when not found
[ "Find", "a", "single", "listener", "by", "its", "object" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/lib/timeline/timeline.js#L5350-L5359
14,813
humangeo/leaflet-dvf
examples/lib/timeline/timeline.js
function (object, event, properties) { var index = this.indexOf(object); var listener = this.listeners[index]; if (listener) { var callbacks = listener.events[event]; if (callbacks) { for (var i = 0, iMax = callbacks.length; i < iMax; i++) { callbacks[i](properties); } } } }
javascript
function (object, event, properties) { var index = this.indexOf(object); var listener = this.listeners[index]; if (listener) { var callbacks = listener.events[event]; if (callbacks) { for (var i = 0, iMax = callbacks.length; i < iMax; i++) { callbacks[i](properties); } } } }
[ "function", "(", "object", ",", "event", ",", "properties", ")", "{", "var", "index", "=", "this", ".", "indexOf", "(", "object", ")", ";", "var", "listener", "=", "this", ".", "listeners", "[", "index", "]", ";", "if", "(", "listener", ")", "{", "...
Trigger an event. All registered event handlers will be called @param {Object} object @param {String} event @param {Object} properties (optional)
[ "Trigger", "an", "event", ".", "All", "registered", "event", "handlers", "will", "be", "called" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/lib/timeline/timeline.js#L5441-L5452
14,814
humangeo/leaflet-dvf
examples/lib/timeline/timeline.js
isLoaded
function isLoaded (url) { if (urls[url] == true) { return true; } var image = new Image(); image.src = url; if (image.complete) { return true; } return false; }
javascript
function isLoaded (url) { if (urls[url] == true) { return true; } var image = new Image(); image.src = url; if (image.complete) { return true; } return false; }
[ "function", "isLoaded", "(", "url", ")", "{", "if", "(", "urls", "[", "url", "]", "==", "true", ")", "{", "return", "true", ";", "}", "var", "image", "=", "new", "Image", "(", ")", ";", "image", ".", "src", "=", "url", ";", "if", "(", "image", ...
the urls currently being loaded. Each key contains an array with callbacks Check if an image url is loaded @param {String} url @return {boolean} loaded True when loaded, false when not loaded or when being loaded
[ "the", "urls", "currently", "being", "loaded", ".", "Each", "key", "contains", "an", "array", "with", "callbacks", "Check", "if", "an", "image", "url", "is", "loaded" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/lib/timeline/timeline.js#L5963-L5975
14,815
humangeo/leaflet-dvf
examples/lib/timeline/timeline.js
load
function load (url, callback, sendCallbackWhenAlreadyLoaded) { if (sendCallbackWhenAlreadyLoaded == undefined) { sendCallbackWhenAlreadyLoaded = true; } if (isLoaded(url)) { if (sendCallbackWhenAlreadyLoaded) { callback(url); } return; } if (isLoading(url) && !sendCallbackWhenAlreadyLoaded) { return; } var c = callbacks[url]; if (!c) { var image = new Image(); image.src = url; c = []; callbacks[url] = c; image.onload = function (event) { urls[url] = true; delete callbacks[url]; for (var i = 0; i < c.length; i++) { c[i](url); } } } if (c.indexOf(callback) == -1) { c.push(callback); } }
javascript
function load (url, callback, sendCallbackWhenAlreadyLoaded) { if (sendCallbackWhenAlreadyLoaded == undefined) { sendCallbackWhenAlreadyLoaded = true; } if (isLoaded(url)) { if (sendCallbackWhenAlreadyLoaded) { callback(url); } return; } if (isLoading(url) && !sendCallbackWhenAlreadyLoaded) { return; } var c = callbacks[url]; if (!c) { var image = new Image(); image.src = url; c = []; callbacks[url] = c; image.onload = function (event) { urls[url] = true; delete callbacks[url]; for (var i = 0; i < c.length; i++) { c[i](url); } } } if (c.indexOf(callback) == -1) { c.push(callback); } }
[ "function", "load", "(", "url", ",", "callback", ",", "sendCallbackWhenAlreadyLoaded", ")", "{", "if", "(", "sendCallbackWhenAlreadyLoaded", "==", "undefined", ")", "{", "sendCallbackWhenAlreadyLoaded", "=", "true", ";", "}", "if", "(", "isLoaded", "(", "url", "...
Load given image url @param {String} url @param {function} callback @param {boolean} sendCallbackWhenAlreadyLoaded optional
[ "Load", "given", "image", "url" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/lib/timeline/timeline.js#L5993-L6030
14,816
humangeo/leaflet-dvf
examples/lib/timeline/timeline.js
loadAll
function loadAll (urls, callback, sendCallbackWhenAlreadyLoaded) { // list all urls which are not yet loaded var urlsLeft = []; urls.forEach(function (url) { if (!isLoaded(url)) { urlsLeft.push(url); } }); if (urlsLeft.length) { // there are unloaded images var countLeft = urlsLeft.length; urlsLeft.forEach(function (url) { load(url, function () { countLeft--; if (countLeft == 0) { // done! callback(); } }, sendCallbackWhenAlreadyLoaded); }); } else { // we are already done! if (sendCallbackWhenAlreadyLoaded) { callback(); } } }
javascript
function loadAll (urls, callback, sendCallbackWhenAlreadyLoaded) { // list all urls which are not yet loaded var urlsLeft = []; urls.forEach(function (url) { if (!isLoaded(url)) { urlsLeft.push(url); } }); if (urlsLeft.length) { // there are unloaded images var countLeft = urlsLeft.length; urlsLeft.forEach(function (url) { load(url, function () { countLeft--; if (countLeft == 0) { // done! callback(); } }, sendCallbackWhenAlreadyLoaded); }); } else { // we are already done! if (sendCallbackWhenAlreadyLoaded) { callback(); } } }
[ "function", "loadAll", "(", "urls", ",", "callback", ",", "sendCallbackWhenAlreadyLoaded", ")", "{", "// list all urls which are not yet loaded", "var", "urlsLeft", "=", "[", "]", ";", "urls", ".", "forEach", "(", "function", "(", "url", ")", "{", "if", "(", "...
Load a set of images, and send a callback as soon as all images are loaded @param {String[]} urls @param {function } callback @param {boolean} sendCallbackWhenAlreadyLoaded
[ "Load", "a", "set", "of", "images", "and", "send", "a", "callback", "as", "soon", "as", "all", "images", "are", "loaded" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/lib/timeline/timeline.js#L6039-L6067
14,817
humangeo/leaflet-dvf
examples/lib/timeline/timeline.js
filterImageUrls
function filterImageUrls (elem, urls) { var child = elem.firstChild; while (child) { if (child.tagName == 'IMG') { var url = child.src; if (urls.indexOf(url) == -1) { urls.push(url); } } filterImageUrls(child, urls); child = child.nextSibling; } }
javascript
function filterImageUrls (elem, urls) { var child = elem.firstChild; while (child) { if (child.tagName == 'IMG') { var url = child.src; if (urls.indexOf(url) == -1) { urls.push(url); } } filterImageUrls(child, urls); child = child.nextSibling; } }
[ "function", "filterImageUrls", "(", "elem", ",", "urls", ")", "{", "var", "child", "=", "elem", ".", "firstChild", ";", "while", "(", "child", ")", "{", "if", "(", "child", ".", "tagName", "==", "'IMG'", ")", "{", "var", "url", "=", "child", ".", "...
Recursively retrieve all image urls from the images located inside a given HTML element @param {Node} elem @param {String[]} urls Urls will be added here (no duplicates)
[ "Recursively", "retrieve", "all", "image", "urls", "from", "the", "images", "located", "inside", "a", "given", "HTML", "element" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/lib/timeline/timeline.js#L6075-L6089
14,818
humangeo/leaflet-dvf
examples/lib/d3.layout.cloud.js
cloudCollide
function cloudCollide(tag, board, sw) { sw >>= 5; var sprite = tag.sprite, w = tag.width >> 5, lx = tag.x - (w << 4), sx = lx & 0x7f, msx = 32 - sx, h = tag.y1 - tag.y0, x = (tag.y + tag.y0) * sw + (lx >> 5), last; for (var j = 0; j < h; j++) { last = 0; for (var i = 0; i <= w; i++) { if (((last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0)) & board[x + i]) return true; } x += sw; } return false; }
javascript
function cloudCollide(tag, board, sw) { sw >>= 5; var sprite = tag.sprite, w = tag.width >> 5, lx = tag.x - (w << 4), sx = lx & 0x7f, msx = 32 - sx, h = tag.y1 - tag.y0, x = (tag.y + tag.y0) * sw + (lx >> 5), last; for (var j = 0; j < h; j++) { last = 0; for (var i = 0; i <= w; i++) { if (((last << msx) | (i < w ? (last = sprite[j * w + i]) >>> sx : 0)) & board[x + i]) return true; } x += sw; } return false; }
[ "function", "cloudCollide", "(", "tag", ",", "board", ",", "sw", ")", "{", "sw", ">>=", "5", ";", "var", "sprite", "=", "tag", ".", "sprite", ",", "w", "=", "tag", ".", "width", ">>", "5", ",", "lx", "=", "tag", ".", "x", "-", "(", "w", "<<",...
Use mask-based collision detection.
[ "Use", "mask", "-", "based", "collision", "detection", "." ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/lib/d3.layout.cloud.js#L293-L312
14,819
humangeo/leaflet-dvf
dist/leaflet-dvf.js
function (properties, featureCollection, mergeKey) { var features = featureCollection.features; var featureIndex = L.GeometryUtils.indexFeatureCollection(features, mergeKey); var property; var mergeValue; var newFeatureCollection = { type: 'FeatureCollection', features: [] }; for (var key in properties) { if (properties.hasOwnProperty(key)) { property = properties[key]; mergeValue = property[mergeKey]; if (mergeValue) { var feature = featureIndex[mergeValue]; for (var prop in property) { feature.properties[prop] = property[prop]; } newFeatureCollection.features.push(feature); } } } return newFeatureCollection; }
javascript
function (properties, featureCollection, mergeKey) { var features = featureCollection.features; var featureIndex = L.GeometryUtils.indexFeatureCollection(features, mergeKey); var property; var mergeValue; var newFeatureCollection = { type: 'FeatureCollection', features: [] }; for (var key in properties) { if (properties.hasOwnProperty(key)) { property = properties[key]; mergeValue = property[mergeKey]; if (mergeValue) { var feature = featureIndex[mergeValue]; for (var prop in property) { feature.properties[prop] = property[prop]; } newFeatureCollection.features.push(feature); } } } return newFeatureCollection; }
[ "function", "(", "properties", ",", "featureCollection", ",", "mergeKey", ")", "{", "var", "features", "=", "featureCollection", ".", "features", ";", "var", "featureIndex", "=", "L", ".", "GeometryUtils", ".", "indexFeatureCollection", "(", "features", ",", "me...
Merges a set of properties into the properties of each feature of a GeoJSON FeatureCollection
[ "Merges", "a", "set", "of", "properties", "into", "the", "properties", "of", "each", "feature", "of", "a", "GeoJSON", "FeatureCollection" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/dist/leaflet-dvf.js#L970-L999
14,820
humangeo/leaflet-dvf
dist/leaflet-dvf.js
function (featureCollection, indexKey) { var features = featureCollection.features; var feature; var properties; var featureIndex = {}; var value; for (var index = 0; index < features.length; ++index) { feature = features[index]; properties = feature.properties; value = properties[indexKey]; // If the value already exists in the index, then either create a GeometryCollection or append the // feature's geometry to the existing GeometryCollection if (value in featureIndex) { var existingFeature = featureIndex[value]; if (existingFeature.geometry.type !== 'GeometryCollection') { featureIndex[value] = { type: 'Feature', geometry: { type: 'GeometryCollection', geometries: [feature.geometry, existingFeature.geometry] } }; } else { existingFeature.geometry.geometries.push(feature.geometry); } } else { featureIndex[value] = feature; } } return featureIndex; }
javascript
function (featureCollection, indexKey) { var features = featureCollection.features; var feature; var properties; var featureIndex = {}; var value; for (var index = 0; index < features.length; ++index) { feature = features[index]; properties = feature.properties; value = properties[indexKey]; // If the value already exists in the index, then either create a GeometryCollection or append the // feature's geometry to the existing GeometryCollection if (value in featureIndex) { var existingFeature = featureIndex[value]; if (existingFeature.geometry.type !== 'GeometryCollection') { featureIndex[value] = { type: 'Feature', geometry: { type: 'GeometryCollection', geometries: [feature.geometry, existingFeature.geometry] } }; } else { existingFeature.geometry.geometries.push(feature.geometry); } } else { featureIndex[value] = feature; } } return featureIndex; }
[ "function", "(", "featureCollection", ",", "indexKey", ")", "{", "var", "features", "=", "featureCollection", ".", "features", ";", "var", "feature", ";", "var", "properties", ";", "var", "featureIndex", "=", "{", "}", ";", "var", "value", ";", "for", "(",...
Indexes a GeoJSON FeatureCollection using the provided key
[ "Indexes", "a", "GeoJSON", "FeatureCollection", "using", "the", "provided", "key" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/dist/leaflet-dvf.js#L1002-L1040
14,821
humangeo/leaflet-dvf
dist/leaflet-dvf.js
function (element, style) { var styleString = ''; for (var key in style) { styleString += key + ': ' + style[key] + ';'; } element.setAttribute('style', styleString); return element; }
javascript
function (element, style) { var styleString = ''; for (var key in style) { styleString += key + ': ' + style[key] + ';'; } element.setAttribute('style', styleString); return element; }
[ "function", "(", "element", ",", "style", ")", "{", "var", "styleString", "=", "''", ";", "for", "(", "var", "key", "in", "style", ")", "{", "styleString", "+=", "key", "+", "': '", "+", "style", "[", "key", "]", "+", "';'", ";", "}", "element", ...
Set element style
[ "Set", "element", "style" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/dist/leaflet-dvf.js#L2546-L2556
14,822
humangeo/leaflet-dvf
dist/leaflet-dvf.js
function (element, attr) { for (var key in attr) { element.setAttribute(key, attr[key]); } return element; }
javascript
function (element, attr) { for (var key in attr) { element.setAttribute(key, attr[key]); } return element; }
[ "function", "(", "element", ",", "attr", ")", "{", "for", "(", "var", "key", "in", "attr", ")", "{", "element", ".", "setAttribute", "(", "key", ",", "attr", "[", "key", "]", ")", ";", "}", "return", "element", ";", "}" ]
Set attributes for an element
[ "Set", "attributes", "for", "an", "element" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/dist/leaflet-dvf.js#L2559-L2565
14,823
humangeo/leaflet-dvf
dist/leaflet-dvf.js
function (location, options, record) { var marker; if (location) { if (options.numberOfSides >= 30 && !(options.innerRadius || (options.innerRadiusX && options.innerRadiusY))) { marker = new L.CircleMarker(location, options); } else { marker = new L.RegularPolygonMarker(location, options); } } return marker; }
javascript
function (location, options, record) { var marker; if (location) { if (options.numberOfSides >= 30 && !(options.innerRadius || (options.innerRadiusX && options.innerRadiusY))) { marker = new L.CircleMarker(location, options); } else { marker = new L.RegularPolygonMarker(location, options); } } return marker; }
[ "function", "(", "location", ",", "options", ",", "record", ")", "{", "var", "marker", ";", "if", "(", "location", ")", "{", "if", "(", "options", ".", "numberOfSides", ">=", "30", "&&", "!", "(", "options", ".", "innerRadius", "||", "(", "options", ...
Can be overridden by specifying a getMarker option
[ "Can", "be", "overridden", "by", "specifying", "a", "getMarker", "option" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/dist/leaflet-dvf.js#L5364-L5377
14,824
humangeo/leaflet-dvf
examples/js/earthquakes.js
function (data) { // Initialize framework linear functions for mapping earthquake data properties to Leaflet style properties // Color scale - green to red using the basic HSLHueFunction var magnitudeColorFunction = new L.HSLHueFunction(new L.Point(0,90), new L.Point(10,0), {outputSaturation: '100%', outputLuminosity: '25%'}); var magnitudeFillColorFunction = new L.HSLHueFunction(new L.Point(0,90), new L.Point(10,0), {outputSaturation: '100%', outputLuminosity: '50%'}); var magnitudeRadiusFunction = new L.LinearFunction(new L.Point(0,10), new L.Point(10,30)); // Color scale - white to orange to red using a PiecewiseFunction // NOTE: Uncomment these lines to see the difference /* var magnitudeColorFunction = new L.PiecewiseFunction([ new L.HSLLuminosityFunction(new L.Point(0,0.8), new L.Point(4,0.3), {outputSaturation: '100%', outputHue: 30}), new L.HSLHueFunction(new L.Point(4,30), new L.Point(10,0), {outputLuminosity: '30%'}) ]); var magnitudeFillColorFunction = new L.PiecewiseFunction([ new L.HSLLuminosityFunction(new L.Point(0,1), new L.Point(4,0.5), {outputSaturation: '100%', outputHue: 30}), new L.HSLHueFunction(new L.Point(4,30), new L.Point(10,0)) ]); */ var now = Math.round((new Date()).getTime()); var start = now - 86400000; // Initialize a linear function to map earthquake time to opacity var timeOpacityFunction = new L.LinearFunction(new L.Point(start,0.3), new L.Point(now,1)); var fontSizeFunction = new L.LinearFunction(new L.Point(0,8), new L.Point(10,24)); var textFunction = function (value) { return { text: value, style: { 'font-size': fontSizeFunction.evaluate(value) } }; }; // Setup a new data layer var dataLayer = new L.DataLayer(data,{ recordsField: 'features', latitudeField: 'geometry.coordinates.1', longitudeField: 'geometry.coordinates.0', locationMode: L.LocationModes.LATLNG, displayOptions: { 'properties.mag': { displayName: 'Magnitude', color: magnitudeColorFunction, fillColor: magnitudeFillColorFunction, radius: magnitudeRadiusFunction, text: textFunction }, 'properties.time': { displayName: 'Time', opacity: timeOpacityFunction, fillOpacity: timeOpacityFunction, displayText: function (value) { return moment.unix(value/1000).format('MM/DD/YY HH:mm'); } } }, layerOptions: { numberOfSides: 4, radius: 10, weight: 1, color: '#000', opacity: 0.2, stroke: true, fillOpacity: 0.7, dropShadow: true, gradient: true }, tooltipOptions: { iconSize: new L.Point(90,76), iconAnchor: new L.Point(-4,76) }, onEachRecord: function (layer, record, location) { var $html = $(L.HTMLUtils.buildTable(record)); layer.bindPopup($html.wrap('<div/>').parent().html(),{ minWidth: 400, maxWidth: 400 }); } }); // Add the data layer to the map map.addLayer(dataLayer); lastLayer = dataLayer; }
javascript
function (data) { // Initialize framework linear functions for mapping earthquake data properties to Leaflet style properties // Color scale - green to red using the basic HSLHueFunction var magnitudeColorFunction = new L.HSLHueFunction(new L.Point(0,90), new L.Point(10,0), {outputSaturation: '100%', outputLuminosity: '25%'}); var magnitudeFillColorFunction = new L.HSLHueFunction(new L.Point(0,90), new L.Point(10,0), {outputSaturation: '100%', outputLuminosity: '50%'}); var magnitudeRadiusFunction = new L.LinearFunction(new L.Point(0,10), new L.Point(10,30)); // Color scale - white to orange to red using a PiecewiseFunction // NOTE: Uncomment these lines to see the difference /* var magnitudeColorFunction = new L.PiecewiseFunction([ new L.HSLLuminosityFunction(new L.Point(0,0.8), new L.Point(4,0.3), {outputSaturation: '100%', outputHue: 30}), new L.HSLHueFunction(new L.Point(4,30), new L.Point(10,0), {outputLuminosity: '30%'}) ]); var magnitudeFillColorFunction = new L.PiecewiseFunction([ new L.HSLLuminosityFunction(new L.Point(0,1), new L.Point(4,0.5), {outputSaturation: '100%', outputHue: 30}), new L.HSLHueFunction(new L.Point(4,30), new L.Point(10,0)) ]); */ var now = Math.round((new Date()).getTime()); var start = now - 86400000; // Initialize a linear function to map earthquake time to opacity var timeOpacityFunction = new L.LinearFunction(new L.Point(start,0.3), new L.Point(now,1)); var fontSizeFunction = new L.LinearFunction(new L.Point(0,8), new L.Point(10,24)); var textFunction = function (value) { return { text: value, style: { 'font-size': fontSizeFunction.evaluate(value) } }; }; // Setup a new data layer var dataLayer = new L.DataLayer(data,{ recordsField: 'features', latitudeField: 'geometry.coordinates.1', longitudeField: 'geometry.coordinates.0', locationMode: L.LocationModes.LATLNG, displayOptions: { 'properties.mag': { displayName: 'Magnitude', color: magnitudeColorFunction, fillColor: magnitudeFillColorFunction, radius: magnitudeRadiusFunction, text: textFunction }, 'properties.time': { displayName: 'Time', opacity: timeOpacityFunction, fillOpacity: timeOpacityFunction, displayText: function (value) { return moment.unix(value/1000).format('MM/DD/YY HH:mm'); } } }, layerOptions: { numberOfSides: 4, radius: 10, weight: 1, color: '#000', opacity: 0.2, stroke: true, fillOpacity: 0.7, dropShadow: true, gradient: true }, tooltipOptions: { iconSize: new L.Point(90,76), iconAnchor: new L.Point(-4,76) }, onEachRecord: function (layer, record, location) { var $html = $(L.HTMLUtils.buildTable(record)); layer.bindPopup($html.wrap('<div/>').parent().html(),{ minWidth: 400, maxWidth: 400 }); } }); // Add the data layer to the map map.addLayer(dataLayer); lastLayer = dataLayer; }
[ "function", "(", "data", ")", "{", "// Initialize framework linear functions for mapping earthquake data properties to Leaflet style properties", "// Color scale - green to red using the basic HSLHueFunction", "var", "magnitudeColorFunction", "=", "new", "L", ".", "HSLHueFunction", "(", ...
JSONP callback function for displaying the latest earthquake data
[ "JSONP", "callback", "function", "for", "displaying", "the", "latest", "earthquake", "data" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/js/earthquakes.js#L6-L96
14,825
humangeo/leaflet-dvf
examples/js/earthquakes.js
function () { if (lastLayer) { map.removeLayer(lastLayer); } $.ajax({ //url: 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/all/day', url: 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojsonp', type: 'GET', dataType: 'jsonp', jsonp: false }); }
javascript
function () { if (lastLayer) { map.removeLayer(lastLayer); } $.ajax({ //url: 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/all/day', url: 'http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojsonp', type: 'GET', dataType: 'jsonp', jsonp: false }); }
[ "function", "(", ")", "{", "if", "(", "lastLayer", ")", "{", "map", ".", "removeLayer", "(", "lastLayer", ")", ";", "}", "$", ".", "ajax", "(", "{", "//url: 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/all/day',", "url", ":", "'http://earthquake.usgs.gov/ea...
Function for requesting the latest earthquakes from USGS
[ "Function", "for", "requesting", "the", "latest", "earthquakes", "from", "USGS" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/js/earthquakes.js#L149-L162
14,826
humangeo/leaflet-dvf
examples/js/panoramio.js
function () { var selected = timeline.getSelection(); if (selected.length > 0) { var row = selected[0].row; var item = timeline.getItem(row); var id = $(item.content).attr('data-id'); var layer = layers[id]; if (lastLayer && lastLayer.viewedImage) { lastLayer.viewedImage.fire('click'); } layer._map.panTo(layer.getLatLng()); layer.fire('click'); lastLayer = layer; } }
javascript
function () { var selected = timeline.getSelection(); if (selected.length > 0) { var row = selected[0].row; var item = timeline.getItem(row); var id = $(item.content).attr('data-id'); var layer = layers[id]; if (lastLayer && lastLayer.viewedImage) { lastLayer.viewedImage.fire('click'); } layer._map.panTo(layer.getLatLng()); layer.fire('click'); lastLayer = layer; } }
[ "function", "(", ")", "{", "var", "selected", "=", "timeline", ".", "getSelection", "(", ")", ";", "if", "(", "selected", ".", "length", ">", "0", ")", "{", "var", "row", "=", "selected", "[", "0", "]", ".", "row", ";", "var", "item", "=", "timel...
Function that will be called when a user clicks on a timeline item
[ "Function", "that", "will", "be", "called", "when", "a", "user", "clicks", "on", "a", "timeline", "item" ]
79aba9f4e7b5a7329c88446562b7affdab00475b
https://github.com/humangeo/leaflet-dvf/blob/79aba9f4e7b5a7329c88446562b7affdab00475b/examples/js/panoramio.js#L55-L75
14,827
octokit/routes
lib/options/urls.js
parseUrlsOption
async function parseUrlsOption (state, urls) { if (!urls || urls.length === 0) { // get URLs for all sections across all pages const pages = await getDocPages(state) return (await pages.reduce(toSectionUrls.bind(null, state), [])).map(normalizeUrl) } const normalizedUrls = urls.map(normalizeUrl) const invalidUrls = normalizedUrls.filter(isntV3DocumentationUrl) if (invalidUrls.length) { throw new Error(`Invalid URLs: ${invalidUrls.join(', ')}`) } const pageUrls = normalizedUrls.filter(isPageUrl) const sectionUrls = normalizedUrls.filter(isSectionUrl) return _.uniq((await pageUrls.reduce(toSectionUrls.bind(null, state), [])).concat(sectionUrls)) }
javascript
async function parseUrlsOption (state, urls) { if (!urls || urls.length === 0) { // get URLs for all sections across all pages const pages = await getDocPages(state) return (await pages.reduce(toSectionUrls.bind(null, state), [])).map(normalizeUrl) } const normalizedUrls = urls.map(normalizeUrl) const invalidUrls = normalizedUrls.filter(isntV3DocumentationUrl) if (invalidUrls.length) { throw new Error(`Invalid URLs: ${invalidUrls.join(', ')}`) } const pageUrls = normalizedUrls.filter(isPageUrl) const sectionUrls = normalizedUrls.filter(isSectionUrl) return _.uniq((await pageUrls.reduce(toSectionUrls.bind(null, state), [])).concat(sectionUrls)) }
[ "async", "function", "parseUrlsOption", "(", "state", ",", "urls", ")", "{", "if", "(", "!", "urls", "||", "urls", ".", "length", "===", "0", ")", "{", "// get URLs for all sections across all pages", "const", "pages", "=", "await", "getDocPages", "(", "state"...
returns all section URLs from all documentation pages by default If URLs are passed than the page URLs are turned into their section URLs
[ "returns", "all", "section", "URLs", "from", "all", "documentation", "pages", "by", "default", "If", "URLs", "are", "passed", "than", "the", "page", "URLs", "are", "turned", "into", "their", "section", "URLs" ]
5859c3847204569c3c22e15aa0006da4ee940f53
https://github.com/octokit/routes/blob/5859c3847204569c3c22e15aa0006da4ee940f53/lib/options/urls.js#L13-L30
14,828
octokit/routes
lib/endpoint/find-parameters.js
replaceTimeNowDefault
function replaceTimeNowDefault (state) { state.results.forEach(output => { output.params.forEach(result => { if (result.default === 'Time.now') { result.default = '<current date/time>' } }) }) }
javascript
function replaceTimeNowDefault (state) { state.results.forEach(output => { output.params.forEach(result => { if (result.default === 'Time.now') { result.default = '<current date/time>' } }) }) }
[ "function", "replaceTimeNowDefault", "(", "state", ")", "{", "state", ".", "results", ".", "forEach", "(", "output", "=>", "{", "output", ".", "params", ".", "forEach", "(", "result", "=>", "{", "if", "(", "result", ".", "default", "===", "'Time.now'", "...
fixing Time.now
[ "fixing", "Time", ".", "now" ]
5859c3847204569c3c22e15aa0006da4ee940f53
https://github.com/octokit/routes/blob/5859c3847204569c3c22e15aa0006da4ee940f53/lib/endpoint/find-parameters.js#L290-L298
14,829
wswebcreation/multiple-cucumber-html-reporter
lib/generate-report.js
_parseScenarios
function _parseScenarios(feature) { feature.elements.forEach(scenario => { scenario.passed = 0; scenario.failed = 0; scenario.notDefined = 0; scenario.skipped = 0; scenario.pending = 0; scenario.ambiguous = 0; scenario.duration = 0; scenario.time = '00:00:00.000'; scenario = _parseSteps(scenario); if (scenario.duration > 0) { feature.duration += scenario.duration; scenario.time = formatDuration(scenario.duration) } if (scenario.hasOwnProperty('description') && scenario.description) { scenario.description = scenario.description.replace(new RegExp('\r?\n', 'g'), "<br />"); } if (scenario.failed > 0) { suite.scenarios.total++; suite.scenarios.failed++; feature.scenarios.total++; feature.isFailed = true; return feature.scenarios.failed++; } if (scenario.ambiguous > 0) { suite.scenarios.total++; suite.scenarios.ambiguous++; feature.scenarios.total++; feature.isAmbiguous = true; return feature.scenarios.ambiguous++; } if (scenario.notDefined > 0) { suite.scenarios.total++; suite.scenarios.notDefined++; feature.scenarios.total++; feature.isNotdefined = true; return feature.scenarios.notDefined++; } if (scenario.pending > 0) { suite.scenarios.total++; suite.scenarios.pending++; feature.scenarios.total++; feature.isPending = true; return feature.scenarios.pending++; } if (scenario.skipped > 0) { suite.scenarios.total++; suite.scenarios.skipped++; feature.scenarios.total++; return feature.scenarios.skipped++; } /* istanbul ignore else */ if (scenario.passed > 0) { suite.scenarios.total++; suite.scenarios.passed++; feature.scenarios.total++; return feature.scenarios.passed++; } }); feature.isSkipped = feature.scenarios.total === feature.scenarios.skipped; return feature; }
javascript
function _parseScenarios(feature) { feature.elements.forEach(scenario => { scenario.passed = 0; scenario.failed = 0; scenario.notDefined = 0; scenario.skipped = 0; scenario.pending = 0; scenario.ambiguous = 0; scenario.duration = 0; scenario.time = '00:00:00.000'; scenario = _parseSteps(scenario); if (scenario.duration > 0) { feature.duration += scenario.duration; scenario.time = formatDuration(scenario.duration) } if (scenario.hasOwnProperty('description') && scenario.description) { scenario.description = scenario.description.replace(new RegExp('\r?\n', 'g'), "<br />"); } if (scenario.failed > 0) { suite.scenarios.total++; suite.scenarios.failed++; feature.scenarios.total++; feature.isFailed = true; return feature.scenarios.failed++; } if (scenario.ambiguous > 0) { suite.scenarios.total++; suite.scenarios.ambiguous++; feature.scenarios.total++; feature.isAmbiguous = true; return feature.scenarios.ambiguous++; } if (scenario.notDefined > 0) { suite.scenarios.total++; suite.scenarios.notDefined++; feature.scenarios.total++; feature.isNotdefined = true; return feature.scenarios.notDefined++; } if (scenario.pending > 0) { suite.scenarios.total++; suite.scenarios.pending++; feature.scenarios.total++; feature.isPending = true; return feature.scenarios.pending++; } if (scenario.skipped > 0) { suite.scenarios.total++; suite.scenarios.skipped++; feature.scenarios.total++; return feature.scenarios.skipped++; } /* istanbul ignore else */ if (scenario.passed > 0) { suite.scenarios.total++; suite.scenarios.passed++; feature.scenarios.total++; return feature.scenarios.passed++; } }); feature.isSkipped = feature.scenarios.total === feature.scenarios.skipped; return feature; }
[ "function", "_parseScenarios", "(", "feature", ")", "{", "feature", ".", "elements", ".", "forEach", "(", "scenario", "=>", "{", "scenario", ".", "passed", "=", "0", ";", "scenario", ".", "failed", "=", "0", ";", "scenario", ".", "notDefined", "=", "0", ...
Parse each scenario within a feature @param {object} feature a feature with all the scenarios in it @return {object} return the parsed feature @private
[ "Parse", "each", "scenario", "within", "a", "feature" ]
149c9e177fc09261769e3e682e4357c9d7931573
https://github.com/wswebcreation/multiple-cucumber-html-reporter/blob/149c9e177fc09261769e3e682e4357c9d7931573/lib/generate-report.js#L239-L312
14,830
wswebcreation/multiple-cucumber-html-reporter
lib/generate-report.js
_readTemplateFile
function _readTemplateFile(fileName) { if (fileName) { try { fs.accessSync(fileName, fs.constants.R_OK); return fs.readFileSync(fileName, 'utf-8'); } catch (err) { return fs.readFileSync(path.join(__dirname, '..', 'templates', fileName), 'utf-8'); } } else { return ""; } }
javascript
function _readTemplateFile(fileName) { if (fileName) { try { fs.accessSync(fileName, fs.constants.R_OK); return fs.readFileSync(fileName, 'utf-8'); } catch (err) { return fs.readFileSync(path.join(__dirname, '..', 'templates', fileName), 'utf-8'); } } else { return ""; } }
[ "function", "_readTemplateFile", "(", "fileName", ")", "{", "if", "(", "fileName", ")", "{", "try", "{", "fs", ".", "accessSync", "(", "fileName", ",", "fs", ".", "constants", ".", "R_OK", ")", ";", "return", "fs", ".", "readFileSync", "(", "fileName", ...
Read a template file and return it's content @param {string} fileName @return {*} Content of the file @private
[ "Read", "a", "template", "file", "and", "return", "it", "s", "content" ]
149c9e177fc09261769e3e682e4357c9d7931573
https://github.com/wswebcreation/multiple-cucumber-html-reporter/blob/149c9e177fc09261769e3e682e4357c9d7931573/lib/generate-report.js#L400-L411
14,831
wswebcreation/multiple-cucumber-html-reporter
lib/generate-report.js
_isBase64
function _isBase64(string) { const notBase64 = /[^A-Z0-9+\/=]/i; const stringLength = string.length; if (!stringLength || stringLength % 4 !== 0 || notBase64.test(string)) { return false; } const firstPaddingChar = string.indexOf('='); return firstPaddingChar === -1 || firstPaddingChar === stringLength - 1 || (firstPaddingChar === stringLength - 2 && string[stringLength - 1] === '='); }
javascript
function _isBase64(string) { const notBase64 = /[^A-Z0-9+\/=]/i; const stringLength = string.length; if (!stringLength || stringLength % 4 !== 0 || notBase64.test(string)) { return false; } const firstPaddingChar = string.indexOf('='); return firstPaddingChar === -1 || firstPaddingChar === stringLength - 1 || (firstPaddingChar === stringLength - 2 && string[stringLength - 1] === '='); }
[ "function", "_isBase64", "(", "string", ")", "{", "const", "notBase64", "=", "/", "[^A-Z0-9+\\/=]", "/", "i", ";", "const", "stringLength", "=", "string", ".", "length", ";", "if", "(", "!", "stringLength", "||", "stringLength", "%", "4", "!==", "0", "||...
Check if the string a base64 string @param string @return {boolean} @private
[ "Check", "if", "the", "string", "a", "base64", "string" ]
149c9e177fc09261769e3e682e4357c9d7931573
https://github.com/wswebcreation/multiple-cucumber-html-reporter/blob/149c9e177fc09261769e3e682e4357c9d7931573/lib/generate-report.js#L419-L432
14,832
wswebcreation/multiple-cucumber-html-reporter
lib/generate-report.js
_createFeaturesOverviewIndexPage
function _createFeaturesOverviewIndexPage(suite) { const featuresOverviewIndex = path.resolve(reportPath, INDEX_HTML); FEATURES_OVERVIEW_TEMPLATE = suite.customMetadata ? FEATURES_OVERVIEW_CUSTOM_METADATA_TEMPLATE : FEATURES_OVERVIEW_TEMPLATE; fs.writeFileSync( featuresOverviewIndex, _.template(_readTemplateFile(FEATURES_OVERVIEW_INDEX_TEMPLATE))({ suite: suite, featuresOverview: _.template(_readTemplateFile(FEATURES_OVERVIEW_TEMPLATE))({ suite: suite, _: _ }), featuresScenariosOverviewChart: _.template(_readTemplateFile(SCENARIOS_OVERVIEW_CHART_TEMPLATE))({ overviewPage: true, scenarios: suite.scenarios, _: _ }), customDataOverview: _.template(_readTemplateFile(CUSTOMDATA_TEMPLATE))({ suite: suite, _: _ }), featuresOverviewChart: _.template(_readTemplateFile(FEATURES_OVERVIEW_CHART_TEMPLATE))({ suite: suite, _: _ }), customStyle: _readTemplateFile(suite.customStyle), styles: _readTemplateFile(suite.style), genericScript: _readTemplateFile(GENERIC_JS), pageTitle: pageTitle, reportName: reportName, pageFooter: pageFooter }) ); }
javascript
function _createFeaturesOverviewIndexPage(suite) { const featuresOverviewIndex = path.resolve(reportPath, INDEX_HTML); FEATURES_OVERVIEW_TEMPLATE = suite.customMetadata ? FEATURES_OVERVIEW_CUSTOM_METADATA_TEMPLATE : FEATURES_OVERVIEW_TEMPLATE; fs.writeFileSync( featuresOverviewIndex, _.template(_readTemplateFile(FEATURES_OVERVIEW_INDEX_TEMPLATE))({ suite: suite, featuresOverview: _.template(_readTemplateFile(FEATURES_OVERVIEW_TEMPLATE))({ suite: suite, _: _ }), featuresScenariosOverviewChart: _.template(_readTemplateFile(SCENARIOS_OVERVIEW_CHART_TEMPLATE))({ overviewPage: true, scenarios: suite.scenarios, _: _ }), customDataOverview: _.template(_readTemplateFile(CUSTOMDATA_TEMPLATE))({ suite: suite, _: _ }), featuresOverviewChart: _.template(_readTemplateFile(FEATURES_OVERVIEW_CHART_TEMPLATE))({ suite: suite, _: _ }), customStyle: _readTemplateFile(suite.customStyle), styles: _readTemplateFile(suite.style), genericScript: _readTemplateFile(GENERIC_JS), pageTitle: pageTitle, reportName: reportName, pageFooter: pageFooter }) ); }
[ "function", "_createFeaturesOverviewIndexPage", "(", "suite", ")", "{", "const", "featuresOverviewIndex", "=", "path", ".", "resolve", "(", "reportPath", ",", "INDEX_HTML", ")", ";", "FEATURES_OVERVIEW_TEMPLATE", "=", "suite", ".", "customMetadata", "?", "FEATURES_OVE...
Generate the features overview @param {object} suite JSON object with all the features and scenarios @private
[ "Generate", "the", "features", "overview" ]
149c9e177fc09261769e3e682e4357c9d7931573
https://github.com/wswebcreation/multiple-cucumber-html-reporter/blob/149c9e177fc09261769e3e682e4357c9d7931573/lib/generate-report.js#L439-L474
14,833
wswebcreation/multiple-cucumber-html-reporter
lib/generate-report.js
_createFeatureIndexPages
function _createFeatureIndexPages(suite) { // Set custom metadata overview for the feature FEATURE_METADATA_OVERVIEW_TEMPLATE = suite.customMetadata ? FEATURE_CUSTOM_METADATA_OVERVIEW_TEMPLATE : FEATURE_METADATA_OVERVIEW_TEMPLATE; suite.features.forEach(feature => { const featurePage = path.resolve(reportPath, `${FEATURE_FOLDER}/${feature.id}.html`); fs.writeFileSync( featurePage, _.template(_readTemplateFile(FEATURE_OVERVIEW_INDEX_TEMPLATE))({ feature: feature, featureScenariosOverviewChart: _.template(_readTemplateFile(SCENARIOS_OVERVIEW_CHART_TEMPLATE))({ overviewPage: false, feature: feature, suite: suite, scenarios: feature.scenarios, _: _ }), featureMetadataOverview: _.template(_readTemplateFile(FEATURE_METADATA_OVERVIEW_TEMPLATE))({ metadata: feature.metadata, _: _ }), scenarioTemplate: _.template(_readTemplateFile(SCENARIOS_TEMPLATE))({ suite: suite, scenarios: feature.elements, _: _ }), customStyle: _readTemplateFile(suite.customStyle), styles: _readTemplateFile(suite.style), genericScript: _readTemplateFile(GENERIC_JS), pageTitle: pageTitle, reportName: reportName, pageFooter: pageFooter, }) ); // Copy the assets fs.copySync( path.resolve(path.dirname(require.resolve("../package.json")),'templates/assets'), path.resolve(reportPath, 'assets') ); }); }
javascript
function _createFeatureIndexPages(suite) { // Set custom metadata overview for the feature FEATURE_METADATA_OVERVIEW_TEMPLATE = suite.customMetadata ? FEATURE_CUSTOM_METADATA_OVERVIEW_TEMPLATE : FEATURE_METADATA_OVERVIEW_TEMPLATE; suite.features.forEach(feature => { const featurePage = path.resolve(reportPath, `${FEATURE_FOLDER}/${feature.id}.html`); fs.writeFileSync( featurePage, _.template(_readTemplateFile(FEATURE_OVERVIEW_INDEX_TEMPLATE))({ feature: feature, featureScenariosOverviewChart: _.template(_readTemplateFile(SCENARIOS_OVERVIEW_CHART_TEMPLATE))({ overviewPage: false, feature: feature, suite: suite, scenarios: feature.scenarios, _: _ }), featureMetadataOverview: _.template(_readTemplateFile(FEATURE_METADATA_OVERVIEW_TEMPLATE))({ metadata: feature.metadata, _: _ }), scenarioTemplate: _.template(_readTemplateFile(SCENARIOS_TEMPLATE))({ suite: suite, scenarios: feature.elements, _: _ }), customStyle: _readTemplateFile(suite.customStyle), styles: _readTemplateFile(suite.style), genericScript: _readTemplateFile(GENERIC_JS), pageTitle: pageTitle, reportName: reportName, pageFooter: pageFooter, }) ); // Copy the assets fs.copySync( path.resolve(path.dirname(require.resolve("../package.json")),'templates/assets'), path.resolve(reportPath, 'assets') ); }); }
[ "function", "_createFeatureIndexPages", "(", "suite", ")", "{", "// Set custom metadata overview for the feature", "FEATURE_METADATA_OVERVIEW_TEMPLATE", "=", "suite", ".", "customMetadata", "?", "FEATURE_CUSTOM_METADATA_OVERVIEW_TEMPLATE", ":", "FEATURE_METADATA_OVERVIEW_TEMPLATE", "...
Generate the feature pages @param suite suite JSON object with all the features and scenarios @private
[ "Generate", "the", "feature", "pages" ]
149c9e177fc09261769e3e682e4357c9d7931573
https://github.com/wswebcreation/multiple-cucumber-html-reporter/blob/149c9e177fc09261769e3e682e4357c9d7931573/lib/generate-report.js#L481-L523
14,834
apache/cordova-windows
template/cordova/lib/build.js
parseAndValidateArgs
function parseAndValidateArgs (options) { // parse and validate args var args = nopt({ 'archs': [String], 'appx': String, 'phone': Boolean, 'win': Boolean, 'bundle': Boolean, 'packageCertificateKeyFile': String, 'packageThumbprint': String, 'publisherId': String, 'buildConfig': String, 'buildFlag': [String, Array] }, {}, options.argv, 0); var config = {}; var buildConfig = {}; // Validate args if (options.debug && options.release) { throw new CordovaError('Cannot specify "debug" and "release" options together.'); } if (args.phone && args.win) { throw new CordovaError('Cannot specify "phone" and "win" options together.'); } // get build options/defaults config.buildType = options.release ? 'release' : 'debug'; var archs = options.archs || args.archs; config.buildArchs = archs ? archs.toLowerCase().split(' ') : ['anycpu']; config.phone = !!args.phone; config.win = !!args.win; config.projVerOverride = args.appx; // only set config.bundle if architecture is not anycpu if (args.bundle) { if (config.buildArchs.length > 1 && (config.buildArchs.indexOf('anycpu') > -1 || config.buildArchs.indexOf('any cpu') > -1)) { // Not valid to bundle anycpu with cpu-specific architectures. warn, then don't bundle events.emit('warn', '"anycpu" and CPU-specific architectures were selected. ' + 'This is not valid when enabling bundling with --bundle. Disabling bundling for this build.'); } else { config.bundle = true; } } // if build.json is provided, parse it var buildConfigPath = options.buildConfig || args.buildConfig; if (buildConfigPath) { buildConfig = parseBuildConfig(buildConfigPath, config.buildType); for (var prop in buildConfig) { config[prop] = buildConfig[prop]; } } // Merge buildFlags from build config and CLI arguments into // single array ensuring that ones from CLI take a precedence config.buildFlags = [].concat(buildConfig.buildFlag || [], args.buildFlag || []); // CLI arguments override build.json config if (args.packageCertificateKeyFile) { args.packageCertificateKeyFile = path.resolve(process.cwd(), args.packageCertificateKeyFile); config.packageCertificateKeyFile = args.packageCertificateKeyFile; } config.packageThumbprint = config.packageThumbprint || args.packageThumbprint; config.publisherId = config.publisherId || args.publisherId; return config; }
javascript
function parseAndValidateArgs (options) { // parse and validate args var args = nopt({ 'archs': [String], 'appx': String, 'phone': Boolean, 'win': Boolean, 'bundle': Boolean, 'packageCertificateKeyFile': String, 'packageThumbprint': String, 'publisherId': String, 'buildConfig': String, 'buildFlag': [String, Array] }, {}, options.argv, 0); var config = {}; var buildConfig = {}; // Validate args if (options.debug && options.release) { throw new CordovaError('Cannot specify "debug" and "release" options together.'); } if (args.phone && args.win) { throw new CordovaError('Cannot specify "phone" and "win" options together.'); } // get build options/defaults config.buildType = options.release ? 'release' : 'debug'; var archs = options.archs || args.archs; config.buildArchs = archs ? archs.toLowerCase().split(' ') : ['anycpu']; config.phone = !!args.phone; config.win = !!args.win; config.projVerOverride = args.appx; // only set config.bundle if architecture is not anycpu if (args.bundle) { if (config.buildArchs.length > 1 && (config.buildArchs.indexOf('anycpu') > -1 || config.buildArchs.indexOf('any cpu') > -1)) { // Not valid to bundle anycpu with cpu-specific architectures. warn, then don't bundle events.emit('warn', '"anycpu" and CPU-specific architectures were selected. ' + 'This is not valid when enabling bundling with --bundle. Disabling bundling for this build.'); } else { config.bundle = true; } } // if build.json is provided, parse it var buildConfigPath = options.buildConfig || args.buildConfig; if (buildConfigPath) { buildConfig = parseBuildConfig(buildConfigPath, config.buildType); for (var prop in buildConfig) { config[prop] = buildConfig[prop]; } } // Merge buildFlags from build config and CLI arguments into // single array ensuring that ones from CLI take a precedence config.buildFlags = [].concat(buildConfig.buildFlag || [], args.buildFlag || []); // CLI arguments override build.json config if (args.packageCertificateKeyFile) { args.packageCertificateKeyFile = path.resolve(process.cwd(), args.packageCertificateKeyFile); config.packageCertificateKeyFile = args.packageCertificateKeyFile; } config.packageThumbprint = config.packageThumbprint || args.packageThumbprint; config.publisherId = config.publisherId || args.publisherId; return config; }
[ "function", "parseAndValidateArgs", "(", "options", ")", "{", "// parse and validate args", "var", "args", "=", "nopt", "(", "{", "'archs'", ":", "[", "String", "]", ",", "'appx'", ":", "String", ",", "'phone'", ":", "Boolean", ",", "'win'", ":", "Boolean", ...
Parses and validates buildOptions object and platform-specific CLI arguments, provided via argv field @param {Object} [options] An options object. If not specified, result will be populated with default values. @return {Object} Build configuration, used by other methods
[ "Parses", "and", "validates", "buildOptions", "object", "and", "platform", "-", "specific", "CLI", "arguments", "provided", "via", "argv", "field" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/cordova/lib/build.js#L192-L260
14,835
apache/cordova-windows
cordova-js-src/splashscreen.js
enterFullScreen
function enterFullScreen() { if (Windows.UI.ViewManagement.ApplicationViewBoundsMode) { // else crash on 8.1 var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); view.setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useCoreWindow); view.suppressSystemOverlays = true; } }
javascript
function enterFullScreen() { if (Windows.UI.ViewManagement.ApplicationViewBoundsMode) { // else crash on 8.1 var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); view.setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useCoreWindow); view.suppressSystemOverlays = true; } }
[ "function", "enterFullScreen", "(", ")", "{", "if", "(", "Windows", ".", "UI", ".", "ViewManagement", ".", "ApplicationViewBoundsMode", ")", "{", "// else crash on 8.1", "var", "view", "=", "Windows", ".", "UI", ".", "ViewManagement", ".", "ApplicationView", "."...
Enter fullscreen mode
[ "Enter", "fullscreen", "mode" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/cordova-js-src/splashscreen.js#L200-L206
14,836
apache/cordova-windows
cordova-js-src/splashscreen.js
exitFullScreen
function exitFullScreen() { if (Windows.UI.ViewManagement.ApplicationViewBoundsMode) { // else crash on 8.1 var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); view.setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useVisible); view.suppressSystemOverlays = false; } }
javascript
function exitFullScreen() { if (Windows.UI.ViewManagement.ApplicationViewBoundsMode) { // else crash on 8.1 var view = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); view.setDesiredBoundsMode(Windows.UI.ViewManagement.ApplicationViewBoundsMode.useVisible); view.suppressSystemOverlays = false; } }
[ "function", "exitFullScreen", "(", ")", "{", "if", "(", "Windows", ".", "UI", ".", "ViewManagement", ".", "ApplicationViewBoundsMode", ")", "{", "// else crash on 8.1", "var", "view", "=", "Windows", ".", "UI", ".", "ViewManagement", ".", "ApplicationView", ".",...
Exit fullscreen mode
[ "Exit", "fullscreen", "mode" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/cordova-js-src/splashscreen.js#L209-L215
14,837
apache/cordova-windows
cordova-js-src/splashscreen.js
colorizeTitleBar
function colorizeTitleBar() { var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); if (isWin10UWP && !isBgColorTransparent) { titleInitialBgColor = appView.titleBar.backgroundColor; appView.titleBar.backgroundColor = titleBgColor; appView.titleBar.buttonBackgroundColor = titleBgColor; } }
javascript
function colorizeTitleBar() { var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); if (isWin10UWP && !isBgColorTransparent) { titleInitialBgColor = appView.titleBar.backgroundColor; appView.titleBar.backgroundColor = titleBgColor; appView.titleBar.buttonBackgroundColor = titleBgColor; } }
[ "function", "colorizeTitleBar", "(", ")", "{", "var", "appView", "=", "Windows", ".", "UI", ".", "ViewManagement", ".", "ApplicationView", ".", "getForCurrentView", "(", ")", ";", "if", "(", "isWin10UWP", "&&", "!", "isBgColorTransparent", ")", "{", "titleInit...
Make title bg color match splashscreen bg color
[ "Make", "title", "bg", "color", "match", "splashscreen", "bg", "color" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/cordova-js-src/splashscreen.js#L218-L226
14,838
apache/cordova-windows
cordova-js-src/splashscreen.js
revertTitleBarColor
function revertTitleBarColor() { var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); if (isWin10UWP && !isBgColorTransparent) { appView.titleBar.backgroundColor = titleInitialBgColor; appView.titleBar.buttonBackgroundColor = titleInitialBgColor; } }
javascript
function revertTitleBarColor() { var appView = Windows.UI.ViewManagement.ApplicationView.getForCurrentView(); if (isWin10UWP && !isBgColorTransparent) { appView.titleBar.backgroundColor = titleInitialBgColor; appView.titleBar.buttonBackgroundColor = titleInitialBgColor; } }
[ "function", "revertTitleBarColor", "(", ")", "{", "var", "appView", "=", "Windows", ".", "UI", ".", "ViewManagement", ".", "ApplicationView", ".", "getForCurrentView", "(", ")", ";", "if", "(", "isWin10UWP", "&&", "!", "isBgColorTransparent", ")", "{", "appVie...
Revert title bg color
[ "Revert", "title", "bg", "color" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/cordova-js-src/splashscreen.js#L229-L235
14,839
apache/cordova-windows
cordova-js-src/splashscreen.js
hide
function hide() { if (isVisible()) { var hideFinishCb = function () { WinJS.Utilities.addClass(splashElement, 'hidden'); splashElement.style.opacity = 1; enableUserInteraction(); exitFullScreen(); } // Color reversion before fading is over looks better: revertTitleBarColor(); // https://issues.apache.org/jira/browse/CB-11751 // This can occur when we directly replace whole document.body f.e. in a router. // Note that you should disable the splashscreen in this case or update a container element instead. if (document.getElementById(splashElement.id) == null) { hideFinishCb(); return; } if (fadeSplashScreen) { fadeOut(splashElement, fadeSplashScreenDuration, hideFinishCb); } else { hideFinishCb(); } } }
javascript
function hide() { if (isVisible()) { var hideFinishCb = function () { WinJS.Utilities.addClass(splashElement, 'hidden'); splashElement.style.opacity = 1; enableUserInteraction(); exitFullScreen(); } // Color reversion before fading is over looks better: revertTitleBarColor(); // https://issues.apache.org/jira/browse/CB-11751 // This can occur when we directly replace whole document.body f.e. in a router. // Note that you should disable the splashscreen in this case or update a container element instead. if (document.getElementById(splashElement.id) == null) { hideFinishCb(); return; } if (fadeSplashScreen) { fadeOut(splashElement, fadeSplashScreenDuration, hideFinishCb); } else { hideFinishCb(); } } }
[ "function", "hide", "(", ")", "{", "if", "(", "isVisible", "(", ")", ")", "{", "var", "hideFinishCb", "=", "function", "(", ")", "{", "WinJS", ".", "Utilities", ".", "addClass", "(", "splashElement", ",", "'hidden'", ")", ";", "splashElement", ".", "st...
Removes the extended splash screen if it is currently visible.
[ "Removes", "the", "extended", "splash", "screen", "if", "it", "is", "currently", "visible", "." ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/cordova-js-src/splashscreen.js#L305-L331
14,840
apache/cordova-windows
cordova-js-src/splashscreen.js
activated
function activated(eventObject) { // Retrieve splash screen object splash = eventObject.detail.splashScreen; // Retrieve the window coordinates of the splash screen image. coordinates = splash.imageLocation; // Register an event handler to be executed when the splash screen has been dismissed. splash.addEventListener('dismissed', onSplashScreenDismissed, false); // Listen for window resize events to reposition the extended splash screen image accordingly. // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc... window.addEventListener('resize', onResize, false); }
javascript
function activated(eventObject) { // Retrieve splash screen object splash = eventObject.detail.splashScreen; // Retrieve the window coordinates of the splash screen image. coordinates = splash.imageLocation; // Register an event handler to be executed when the splash screen has been dismissed. splash.addEventListener('dismissed', onSplashScreenDismissed, false); // Listen for window resize events to reposition the extended splash screen image accordingly. // This is important to ensure that the extended splash screen is formatted properly in response to snapping, unsnapping, rotation, etc... window.addEventListener('resize', onResize, false); }
[ "function", "activated", "(", "eventObject", ")", "{", "// Retrieve splash screen object ", "splash", "=", "eventObject", ".", "detail", ".", "splashScreen", ";", "// Retrieve the window coordinates of the splash screen image. ", "coordinates", "=", "splash", ".", "imageLocat...
Object to store splash screen image coordinates. It will be initialized during activation.
[ "Object", "to", "store", "splash", "screen", "image", "coordinates", ".", "It", "will", "be", "initialized", "during", "activation", "." ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/cordova-js-src/splashscreen.js#L338-L351
14,841
apache/cordova-windows
template/cordova/lib/prepare.js
addBOMSignature
function addBOMSignature (directory) { shell.ls('-R', directory) .map(function (file) { return path.join(directory, file); }) .forEach(addBOMToFile); }
javascript
function addBOMSignature (directory) { shell.ls('-R', directory) .map(function (file) { return path.join(directory, file); }) .forEach(addBOMToFile); }
[ "function", "addBOMSignature", "(", "directory", ")", "{", "shell", ".", "ls", "(", "'-R'", ",", "directory", ")", ".", "map", "(", "function", "(", "file", ")", "{", "return", "path", ".", "join", "(", "directory", ",", "file", ")", ";", "}", ")", ...
Adds BOM signature at the beginning of all js|html|css|json files in specified folder and all subfolders. This is required for application to pass Windows store certification successfully. @param {String} directory Directory where we need to update files
[ "Adds", "BOM", "signature", "at", "the", "beginning", "of", "all", "js|html|css|json", "files", "in", "specified", "folder", "and", "all", "subfolders", ".", "This", "is", "required", "for", "application", "to", "pass", "Windows", "store", "certification", "succ...
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/cordova/lib/prepare.js#L660-L666
14,842
apache/cordova-windows
template/cordova/lib/prepare.js
addBOMToFile
function addBOMToFile (file) { if (!file.match(/\.(js|htm|html|css|json)$/i)) { return; } // skip if this is a folder if (!fs.lstatSync(file).isFile()) { return; } var content = fs.readFileSync(file); if (content[0] !== 0xEF && content[1] !== 0xBE && content[2] !== 0xBB) { fs.writeFileSync(file, '\ufeff' + content); } }
javascript
function addBOMToFile (file) { if (!file.match(/\.(js|htm|html|css|json)$/i)) { return; } // skip if this is a folder if (!fs.lstatSync(file).isFile()) { return; } var content = fs.readFileSync(file); if (content[0] !== 0xEF && content[1] !== 0xBE && content[2] !== 0xBB) { fs.writeFileSync(file, '\ufeff' + content); } }
[ "function", "addBOMToFile", "(", "file", ")", "{", "if", "(", "!", "file", ".", "match", "(", "/", "\\.(js|htm|html|css|json)$", "/", "i", ")", ")", "{", "return", ";", "}", "// skip if this is a folder", "if", "(", "!", "fs", ".", "lstatSync", "(", "fil...
Adds BOM signature at the beginning of file, specified by absolute path. Ignores directories and non-js, -html or -css files. @param {String} file Absolute path to file to add BOM to
[ "Adds", "BOM", "signature", "at", "the", "beginning", "of", "file", "specified", "by", "absolute", "path", ".", "Ignores", "directories", "and", "non", "-", "js", "-", "html", "or", "-", "css", "files", "." ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/cordova/lib/prepare.js#L674-L688
14,843
apache/cordova-windows
template/cordova/lib/prepare.js
updateProjectAccordingTo
function updateProjectAccordingTo (projectConfig, locations) { // Apply appxmanifest changes [MANIFEST_WINDOWS, MANIFEST_WINDOWS10, MANIFEST_PHONE] .forEach(function (manifestFile) { updateManifestFile(projectConfig, path.join(locations.root, manifestFile)); }); if (process.platform === 'win32') { applyUAPVersionToProject(path.join(locations.root, PROJECT_WINDOWS10), getUAPVersions(projectConfig)); } }
javascript
function updateProjectAccordingTo (projectConfig, locations) { // Apply appxmanifest changes [MANIFEST_WINDOWS, MANIFEST_WINDOWS10, MANIFEST_PHONE] .forEach(function (manifestFile) { updateManifestFile(projectConfig, path.join(locations.root, manifestFile)); }); if (process.platform === 'win32') { applyUAPVersionToProject(path.join(locations.root, PROJECT_WINDOWS10), getUAPVersions(projectConfig)); } }
[ "function", "updateProjectAccordingTo", "(", "projectConfig", ",", "locations", ")", "{", "// Apply appxmanifest changes", "[", "MANIFEST_WINDOWS", ",", "MANIFEST_WINDOWS10", ",", "MANIFEST_PHONE", "]", ".", "forEach", "(", "function", "(", "manifestFile", ")", "{", "...
Updates project structure and AppxManifest according to project's configuration. @param {ConfigParser} projectConfig A project's configuration that will be used to update project @param {Object} locations A map of locations for this platform
[ "Updates", "project", "structure", "and", "AppxManifest", "according", "to", "project", "s", "configuration", "." ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/cordova/lib/prepare.js#L793-L803
14,844
apache/cordova-windows
spec/unit/pluginHandler/windows.spec.js
function (tag, elementToInstall, xml) { var frameworkCustomPathElement = xml.find(xpath); expect(frameworkCustomPathElement).not.toBe(null); var frameworkCustomPath = frameworkCustomPathElement.text; expect(frameworkCustomPath).not.toBe(null); var targetDir = elementToInstall.targetDir || ''; var frameworkCustomExpectedPath = path.join('plugins', dummyPluginInfo.id, targetDir, path.basename(elementToInstall.src)); expect(frameworkCustomPath).toEqual(frameworkCustomExpectedPath); }
javascript
function (tag, elementToInstall, xml) { var frameworkCustomPathElement = xml.find(xpath); expect(frameworkCustomPathElement).not.toBe(null); var frameworkCustomPath = frameworkCustomPathElement.text; expect(frameworkCustomPath).not.toBe(null); var targetDir = elementToInstall.targetDir || ''; var frameworkCustomExpectedPath = path.join('plugins', dummyPluginInfo.id, targetDir, path.basename(elementToInstall.src)); expect(frameworkCustomPath).toEqual(frameworkCustomExpectedPath); }
[ "function", "(", "tag", ",", "elementToInstall", ",", "xml", ")", "{", "var", "frameworkCustomPathElement", "=", "xml", ".", "find", "(", "xpath", ")", ";", "expect", "(", "frameworkCustomPathElement", ")", ".", "not", ".", "toBe", "(", "null", ")", ";", ...
Check that installed framework reference is properly added to project.
[ "Check", "that", "installed", "framework", "reference", "is", "properly", "added", "to", "project", "." ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/spec/unit/pluginHandler/windows.spec.js#L136-L145
14,845
apache/cordova-windows
spec/unit/pluginHandler/windows.spec.js
function (framework) { var targetDir = framework.targetDir || ''; var dest = path.join(cordovaProjectWindowsPlatformDir, 'plugins', dummyPluginInfo.id, targetDir, path.basename(framework.src)); var copiedSuccessfully = fs.existsSync(path.resolve(dest)); expect(copiedSuccessfully).toBe(true); }
javascript
function (framework) { var targetDir = framework.targetDir || ''; var dest = path.join(cordovaProjectWindowsPlatformDir, 'plugins', dummyPluginInfo.id, targetDir, path.basename(framework.src)); var copiedSuccessfully = fs.existsSync(path.resolve(dest)); expect(copiedSuccessfully).toBe(true); }
[ "function", "(", "framework", ")", "{", "var", "targetDir", "=", "framework", ".", "targetDir", "||", "''", ";", "var", "dest", "=", "path", ".", "join", "(", "cordovaProjectWindowsPlatformDir", ",", "'plugins'", ",", "dummyPluginInfo", ".", "id", ",", "targ...
Check that framework file was copied to correct path
[ "Check", "that", "framework", "file", "was", "copied", "to", "correct", "path" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/spec/unit/pluginHandler/windows.spec.js#L148-L153
14,846
apache/cordova-windows
template/cordova/lib/AppxManifest.js
sortCapabilities
function sortCapabilities (manifest) { // removes namespace prefix (m3:Capability -> Capability) // this is required since elementtree returns qualified name with namespace function extractLocalName (tag) { return tag.split(':').pop(); // takes last part of string after ':' } var capabilitiesRoot = manifest.find('.//Capabilities'); var capabilities = capabilitiesRoot.getchildren() || []; // to sort elements we remove them and then add again in the appropriate order capabilities.forEach(function (elem) { // no .clear() method capabilitiesRoot.remove(elem); // CB-7601 we need local name w/o namespace prefix to sort capabilities correctly elem.localName = extractLocalName(elem.tag); }); capabilities.sort(function (a, b) { return (a.localName > b.localName) ? 1 : -1; }); capabilities.forEach(function (elem) { capabilitiesRoot.append(elem); }); }
javascript
function sortCapabilities (manifest) { // removes namespace prefix (m3:Capability -> Capability) // this is required since elementtree returns qualified name with namespace function extractLocalName (tag) { return tag.split(':').pop(); // takes last part of string after ':' } var capabilitiesRoot = manifest.find('.//Capabilities'); var capabilities = capabilitiesRoot.getchildren() || []; // to sort elements we remove them and then add again in the appropriate order capabilities.forEach(function (elem) { // no .clear() method capabilitiesRoot.remove(elem); // CB-7601 we need local name w/o namespace prefix to sort capabilities correctly elem.localName = extractLocalName(elem.tag); }); capabilities.sort(function (a, b) { return (a.localName > b.localName) ? 1 : -1; }); capabilities.forEach(function (elem) { capabilitiesRoot.append(elem); }); }
[ "function", "sortCapabilities", "(", "manifest", ")", "{", "// removes namespace prefix (m3:Capability -> Capability)", "// this is required since elementtree returns qualified name with namespace", "function", "extractLocalName", "(", "tag", ")", "{", "return", "tag", ".", "split"...
Sorts 'capabilities' elements in manifest in ascending order @param {Elementtree.Document} manifest An XML document that represents appxmanifest
[ "Sorts", "capabilities", "elements", "in", "manifest", "in", "ascending", "order" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/cordova/lib/AppxManifest.js#L619-L641
14,847
apache/cordova-windows
template/www/cordova.js
function (callbackId, isSuccess, status, args, keepCallback) { try { var callback = cordova.callbacks[callbackId]; if (callback) { if (isSuccess && status === cordova.callbackStatus.OK) { callback.success && callback.success.apply(null, args); } else if (!isSuccess) { callback.fail && callback.fail.apply(null, args); } /* else Note, this case is intentionally not caught. this can happen if isSuccess is true, but callbackStatus is NO_RESULT which is used to remove a callback from the list without calling the callbacks typically keepCallback is false in this case */ // Clear callback if not expecting any more results if (!keepCallback) { delete cordova.callbacks[callbackId]; } } } catch (err) { var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err; console && console.log && console.log(msg); console && console.log && err.stack && console.log(err.stack); cordova.fireWindowEvent('cordovacallbackerror', { 'message': msg }); throw err; } }
javascript
function (callbackId, isSuccess, status, args, keepCallback) { try { var callback = cordova.callbacks[callbackId]; if (callback) { if (isSuccess && status === cordova.callbackStatus.OK) { callback.success && callback.success.apply(null, args); } else if (!isSuccess) { callback.fail && callback.fail.apply(null, args); } /* else Note, this case is intentionally not caught. this can happen if isSuccess is true, but callbackStatus is NO_RESULT which is used to remove a callback from the list without calling the callbacks typically keepCallback is false in this case */ // Clear callback if not expecting any more results if (!keepCallback) { delete cordova.callbacks[callbackId]; } } } catch (err) { var msg = 'Error in ' + (isSuccess ? 'Success' : 'Error') + ' callbackId: ' + callbackId + ' : ' + err; console && console.log && console.log(msg); console && console.log && err.stack && console.log(err.stack); cordova.fireWindowEvent('cordovacallbackerror', { 'message': msg }); throw err; } }
[ "function", "(", "callbackId", ",", "isSuccess", ",", "status", ",", "args", ",", "keepCallback", ")", "{", "try", "{", "var", "callback", "=", "cordova", ".", "callbacks", "[", "callbackId", "]", ";", "if", "(", "callback", ")", "{", "if", "(", "isSuc...
Called by native code when returning the result from an action.
[ "Called", "by", "native", "code", "when", "returning", "the", "result", "from", "an", "action", "." ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/www/cordova.js#L283-L311
14,848
apache/cordova-windows
template/cordova/lib/package.js
getPackageName
function getPackageName (platformPath) { // Can reliably read from package.windows.appxmanifest even if targeting Windows 10 // because the function is only used for desktop deployment, which always has the same // package name when uninstalling / reinstalling try { return Q.when(AppxManifest.get(path.join(platformPath, 'package.windows.appxmanifest')) .getIdentity().getName()); } catch (e) { return Q.reject('Can\'t read package name from manifest ' + e); } }
javascript
function getPackageName (platformPath) { // Can reliably read from package.windows.appxmanifest even if targeting Windows 10 // because the function is only used for desktop deployment, which always has the same // package name when uninstalling / reinstalling try { return Q.when(AppxManifest.get(path.join(platformPath, 'package.windows.appxmanifest')) .getIdentity().getName()); } catch (e) { return Q.reject('Can\'t read package name from manifest ' + e); } }
[ "function", "getPackageName", "(", "platformPath", ")", "{", "// Can reliably read from package.windows.appxmanifest even if targeting Windows 10", "// because the function is only used for desktop deployment, which always has the same", "// package name when uninstalling / reinstalling", "try", ...
return package name fetched from appxmanifest return rejected promise if appxmanifest not valid
[ "return", "package", "name", "fetched", "from", "appxmanifest", "return", "rejected", "promise", "if", "appxmanifest", "not", "valid" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/cordova/lib/package.js#L115-L125
14,849
apache/cordova-windows
bin/lib/check_reqs.js
getInstalledVSVersions
function getInstalledVSVersions () { // Query all keys with Install value equal to 1, then filter out // those, which are not related to VS itself return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\DevDiv\\vs\\Servicing', '/s', '/v', 'Install', '/f', '1', '/d', '/e', '/reg:32']) .fail(function () { return ''; }) .then(function (output) { return output.split('\n') .reduce(function (installedVersions, line) { var match = /(\d+\.\d+)\\(ultimate|professional|premium|community)/.exec(line); if (match && match[1] && installedVersions.indexOf(match[1]) === -1) { installedVersions.push(match[1]); } return installedVersions; }, []); }).then(function (installedVersions) { // If there is no VS2013 installed, the we have nothing to do if (installedVersions.indexOf('12.0') === -1) return installedVersions; // special case for VS 2013. We need to check if VS2013 update 2 is installed return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Updates\\Microsoft Visual Studio 2013\\vsupdate_KB2829760', '/v', 'PackageVersion', '/reg:32']) .then(function (output) { var updateVer = Version.fromString(/PackageVersion\s+REG_SZ\s+(.*)/i.exec(output)[1]); // if update version is lover than Update2, reject the promise if (VS2013_UPDATE2_RC.gte(updateVer)) return Q.reject(); return installedVersions; }).fail(function () { // if we got any errors on previous steps, we're assuming that // required VS update is not installed. installedVersions.splice(installedVersions.indexOf('12.0'), 1); return installedVersions; }); }) .then(function (installedVersions) { var willowVersions = MSBuildTools.getWillowInstallations().map(function (installation) { return installation.version; }); return installedVersions.concat(willowVersions); }); }
javascript
function getInstalledVSVersions () { // Query all keys with Install value equal to 1, then filter out // those, which are not related to VS itself return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\DevDiv\\vs\\Servicing', '/s', '/v', 'Install', '/f', '1', '/d', '/e', '/reg:32']) .fail(function () { return ''; }) .then(function (output) { return output.split('\n') .reduce(function (installedVersions, line) { var match = /(\d+\.\d+)\\(ultimate|professional|premium|community)/.exec(line); if (match && match[1] && installedVersions.indexOf(match[1]) === -1) { installedVersions.push(match[1]); } return installedVersions; }, []); }).then(function (installedVersions) { // If there is no VS2013 installed, the we have nothing to do if (installedVersions.indexOf('12.0') === -1) return installedVersions; // special case for VS 2013. We need to check if VS2013 update 2 is installed return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Updates\\Microsoft Visual Studio 2013\\vsupdate_KB2829760', '/v', 'PackageVersion', '/reg:32']) .then(function (output) { var updateVer = Version.fromString(/PackageVersion\s+REG_SZ\s+(.*)/i.exec(output)[1]); // if update version is lover than Update2, reject the promise if (VS2013_UPDATE2_RC.gte(updateVer)) return Q.reject(); return installedVersions; }).fail(function () { // if we got any errors on previous steps, we're assuming that // required VS update is not installed. installedVersions.splice(installedVersions.indexOf('12.0'), 1); return installedVersions; }); }) .then(function (installedVersions) { var willowVersions = MSBuildTools.getWillowInstallations().map(function (installation) { return installation.version; }); return installedVersions.concat(willowVersions); }); }
[ "function", "getInstalledVSVersions", "(", ")", "{", "// Query all keys with Install value equal to 1, then filter out", "// those, which are not related to VS itself", "return", "spawn", "(", "'reg'", ",", "[", "'query'", ",", "'HKLM\\\\SOFTWARE\\\\Microsoft\\\\DevDiv\\\\vs\\\\Servici...
Lists all Visual Studio versions insalled. For VS 2013 if it present, also checks if Update 2 is installed. @return {String[]} List of installed Visual Studio versions.
[ "Lists", "all", "Visual", "Studio", "versions", "insalled", ".", "For", "VS", "2013", "if", "it", "present", "also", "checks", "if", "Update", "2", "is", "installed", "." ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/bin/lib/check_reqs.js#L121-L157
14,850
apache/cordova-windows
bin/lib/check_reqs.js
getInstalledWindowsSdks
function getInstalledWindowsSdks () { var installedSdks = []; return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows', '/s', '/v', 'InstallationFolder', '/reg:32']) .fail(function () { return ''; }) .then(function (output) { var re = /\\Microsoft SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim; var match; while ((match = re.exec(output))) { var sdkPath = match[2]; // Verify that SDKs is really installed by checking SDKManifest file at SDK root if (shell.test('-e', path.join(sdkPath, 'SDKManifest.xml'))) { installedSdks.push(Version.tryParse(match[1])); } } }).thenResolve(installedSdks); }
javascript
function getInstalledWindowsSdks () { var installedSdks = []; return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows', '/s', '/v', 'InstallationFolder', '/reg:32']) .fail(function () { return ''; }) .then(function (output) { var re = /\\Microsoft SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim; var match; while ((match = re.exec(output))) { var sdkPath = match[2]; // Verify that SDKs is really installed by checking SDKManifest file at SDK root if (shell.test('-e', path.join(sdkPath, 'SDKManifest.xml'))) { installedSdks.push(Version.tryParse(match[1])); } } }).thenResolve(installedSdks); }
[ "function", "getInstalledWindowsSdks", "(", ")", "{", "var", "installedSdks", "=", "[", "]", ";", "return", "spawn", "(", "'reg'", ",", "[", "'query'", ",", "'HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows'", ",", "'/s'", ",", "'/v'", ",", "'Installation...
Gets list of installed Windows SDKs @return {Version[]} List of installed SDKs' versions
[ "Gets", "list", "of", "installed", "Windows", "SDKs" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/bin/lib/check_reqs.js#L164-L179
14,851
apache/cordova-windows
bin/lib/check_reqs.js
getInstalledPhoneSdks
function getInstalledPhoneSdks () { var installedSdks = []; return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows Phone\\v8.1', '/v', 'InstallationFolder', '/reg:32']) .fail(function () { return ''; }) .then(function (output) { var match = /\\Microsoft SDKs\\Windows Phone\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim.exec(output); if (match && shell.test('-e', path.join(match[2], 'SDKManifest.xml'))) { installedSdks.push(Version.tryParse(match[1])); } }).then(function () { return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0', '/v', 'InstallationFolder', '/reg:32']); }).fail(function () { return ''; }).then(function (output) { var match = /\\Microsoft SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim.exec(output); if (match && shell.test('-e', path.join(match[2], 'SDKManifest.xml'))) { installedSdks.push(Version.tryParse(match[1])); } }).thenResolve(installedSdks); }
javascript
function getInstalledPhoneSdks () { var installedSdks = []; return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows Phone\\v8.1', '/v', 'InstallationFolder', '/reg:32']) .fail(function () { return ''; }) .then(function (output) { var match = /\\Microsoft SDKs\\Windows Phone\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim.exec(output); if (match && shell.test('-e', path.join(match[2], 'SDKManifest.xml'))) { installedSdks.push(Version.tryParse(match[1])); } }).then(function () { return spawn('reg', ['query', 'HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0', '/v', 'InstallationFolder', '/reg:32']); }).fail(function () { return ''; }).then(function (output) { var match = /\\Microsoft SDKs\\Windows\\v(\d+\.\d+)\s*InstallationFolder\s+REG_SZ\s+(.*)/gim.exec(output); if (match && shell.test('-e', path.join(match[2], 'SDKManifest.xml'))) { installedSdks.push(Version.tryParse(match[1])); } }).thenResolve(installedSdks); }
[ "function", "getInstalledPhoneSdks", "(", ")", "{", "var", "installedSdks", "=", "[", "]", ";", "return", "spawn", "(", "'reg'", ",", "[", "'query'", ",", "'HKLM\\\\SOFTWARE\\\\Microsoft\\\\Microsoft SDKs\\\\Windows Phone\\\\v8.1'", ",", "'/v'", ",", "'InstallationFolde...
Gets list of installed Windows Phone SDKs. Separately searches for 8.1 Phone SDK and Windows 10 SDK, because the latter is needed for both Windows and Windows Phone applications. @return {Version[]} List of installed Phone SDKs' versions.
[ "Gets", "list", "of", "installed", "Windows", "Phone", "SDKs", ".", "Separately", "searches", "for", "8", ".", "1", "Phone", "SDK", "and", "Windows", "10", "SDK", "because", "the", "latter", "is", "needed", "for", "both", "Windows", "and", "Windows", "Phon...
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/bin/lib/check_reqs.js#L188-L207
14,852
apache/cordova-windows
bin/lib/check_reqs.js
function (windowsTargetVersion, windowsPhoneTargetVersion) { if (process.platform !== 'win32') { // Build Universal windows apps available for windows platform only, so we reject on others platforms return Q.reject('Cordova tooling for Windows requires Windows OS to build project'); } return getWindowsVersion().then(function (actualVersion) { var requiredOsVersion = getMinimalRequiredVersionFor('os', windowsTargetVersion, windowsPhoneTargetVersion); if ((actualVersion.gte(requiredOsVersion)) || // Special case for Windows 10/Phone 10 targets which can be built on Windows 7 (version 6.1) (actualVersion.major === 6 && actualVersion.minor === 1 && getConfig().getWindowsTargetVersion() === '10.0')) { return mapWindowsVersionToName(actualVersion); } return Q.reject('Current Windows version doesn\'t support building this project. ' + 'Consider upgrading your OS to ' + mapWindowsVersionToName(requiredOsVersion)); }); }
javascript
function (windowsTargetVersion, windowsPhoneTargetVersion) { if (process.platform !== 'win32') { // Build Universal windows apps available for windows platform only, so we reject on others platforms return Q.reject('Cordova tooling for Windows requires Windows OS to build project'); } return getWindowsVersion().then(function (actualVersion) { var requiredOsVersion = getMinimalRequiredVersionFor('os', windowsTargetVersion, windowsPhoneTargetVersion); if ((actualVersion.gte(requiredOsVersion)) || // Special case for Windows 10/Phone 10 targets which can be built on Windows 7 (version 6.1) (actualVersion.major === 6 && actualVersion.minor === 1 && getConfig().getWindowsTargetVersion() === '10.0')) { return mapWindowsVersionToName(actualVersion); } return Q.reject('Current Windows version doesn\'t support building this project. ' + 'Consider upgrading your OS to ' + mapWindowsVersionToName(requiredOsVersion)); }); }
[ "function", "(", "windowsTargetVersion", ",", "windowsPhoneTargetVersion", ")", "{", "if", "(", "process", ".", "platform", "!==", "'win32'", ")", "{", "// Build Universal windows apps available for windows platform only, so we reject on others platforms", "return", "Q", ".", ...
Check if current OS is supports building windows platform @return {Promise} Promise either fullfilled or rejected with error message.
[ "Check", "if", "current", "OS", "is", "supports", "building", "windows", "platform" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/bin/lib/check_reqs.js#L245-L262
14,853
apache/cordova-windows
template/cordova/lib/MSBuildTools.js
getWillowProgDataPaths
function getWillowProgDataPaths () { if (!process.env.systemdrive) { // running on linux/osx? return []; } var instancesRoot = path.join(process.env.systemdrive, 'ProgramData/Microsoft/VisualStudio/Packages/_Instances'); if (!shell.test('-d', instancesRoot)) { // can't seem to find VS instances dir, return empty result return []; } return fs.readdirSync(instancesRoot).map(function (file) { var instanceDir = path.join(instancesRoot, file); if (shell.test('-d', instanceDir)) { return instanceDir; } }).filter(function (progDataPath) { // make sure state.json exists return shell.test('-e', path.join(progDataPath, 'state.json')); }); }
javascript
function getWillowProgDataPaths () { if (!process.env.systemdrive) { // running on linux/osx? return []; } var instancesRoot = path.join(process.env.systemdrive, 'ProgramData/Microsoft/VisualStudio/Packages/_Instances'); if (!shell.test('-d', instancesRoot)) { // can't seem to find VS instances dir, return empty result return []; } return fs.readdirSync(instancesRoot).map(function (file) { var instanceDir = path.join(instancesRoot, file); if (shell.test('-d', instanceDir)) { return instanceDir; } }).filter(function (progDataPath) { // make sure state.json exists return shell.test('-e', path.join(progDataPath, 'state.json')); }); }
[ "function", "getWillowProgDataPaths", "(", ")", "{", "if", "(", "!", "process", ".", "env", ".", "systemdrive", ")", "{", "// running on linux/osx?", "return", "[", "]", ";", "}", "var", "instancesRoot", "=", "path", ".", "join", "(", "process", ".", "env"...
Lists all VS 2017+ instances dirs in ProgramData @return {String[]} List of paths to all VS2017+ instances
[ "Lists", "all", "VS", "2017", "+", "instances", "dirs", "in", "ProgramData" ]
585dc2f4e4c0794b72af6f4b448bb42ffd213800
https://github.com/apache/cordova-windows/blob/585dc2f4e4c0794b72af6f4b448bb42ffd213800/template/cordova/lib/MSBuildTools.js#L322-L342
14,854
jiggzson/nerdamer
Algebra.js
function(symbol, c) { this.variable = variables(symbol)[0]; if(!symbol.isPoly()) throw core.exceptions.NerdamerTypeError('Polynomial Expected! Received '+core.Utils.text(symbol)); c = c || []; if(!symbol.power.absEquals(1)) symbol = _.expand(symbol); if(symbol.group === core.groups.N) { c[0] = symbol.multiplier; } else if(symbol.group === core.groups.S) { c[symbol.power.toDecimal()] = symbol.multiplier; } else { for(var x in symbol.symbols) { var sub = symbol.symbols[x], p = sub.power; if(core.Utils.isSymbol(p)) throw new core.exceptions.NerdamerTypeError('power cannot be a Symbol'); p = sub.group === N ? 0 : p.toDecimal(); if(sub.symbols){ this.parse(sub, c); } else { c[p] = sub.multiplier; } } } this.coeffs = c; this.fill(); }
javascript
function(symbol, c) { this.variable = variables(symbol)[0]; if(!symbol.isPoly()) throw core.exceptions.NerdamerTypeError('Polynomial Expected! Received '+core.Utils.text(symbol)); c = c || []; if(!symbol.power.absEquals(1)) symbol = _.expand(symbol); if(symbol.group === core.groups.N) { c[0] = symbol.multiplier; } else if(symbol.group === core.groups.S) { c[symbol.power.toDecimal()] = symbol.multiplier; } else { for(var x in symbol.symbols) { var sub = symbol.symbols[x], p = sub.power; if(core.Utils.isSymbol(p)) throw new core.exceptions.NerdamerTypeError('power cannot be a Symbol'); p = sub.group === N ? 0 : p.toDecimal(); if(sub.symbols){ this.parse(sub, c); } else { c[p] = sub.multiplier; } } } this.coeffs = c; this.fill(); }
[ "function", "(", "symbol", ",", "c", ")", "{", "this", ".", "variable", "=", "variables", "(", "symbol", ")", "[", "0", "]", ";", "if", "(", "!", "symbol", ".", "isPoly", "(", ")", ")", "throw", "core", ".", "exceptions", ".", "NerdamerTypeError", ...
Converts Symbol to Polynomial @param {Symbol} symbol @param {Array} c - a collector array @returns {Polynomial}
[ "Converts", "Symbol", "to", "Polynomial" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L110-L137
14,855
jiggzson/nerdamer
Algebra.js
function(x) { x = Number(x) || 0; var l = this.coeffs.length; for(var i=0; i<l; i++) { if(this.coeffs[i] === undefined) { this.coeffs[i] = new Frac(x); } } return this; }
javascript
function(x) { x = Number(x) || 0; var l = this.coeffs.length; for(var i=0; i<l; i++) { if(this.coeffs[i] === undefined) { this.coeffs[i] = new Frac(x); } } return this; }
[ "function", "(", "x", ")", "{", "x", "=", "Number", "(", "x", ")", "||", "0", ";", "var", "l", "=", "this", ".", "coeffs", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "t...
Fills in the holes in a polynomial with zeroes @param {Number} x - The number to fill the holes with
[ "Fills", "in", "the", "holes", "in", "a", "polynomial", "with", "zeroes" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L142-L149
14,856
jiggzson/nerdamer
Algebra.js
function() { var l = this.coeffs.length; while(l--) { var c = this.coeffs[l]; var equalsZero = c.equals(0); if(c && equalsZero) { if(l === 0) break; this.coeffs.pop(); } else break; } return this; }
javascript
function() { var l = this.coeffs.length; while(l--) { var c = this.coeffs[l]; var equalsZero = c.equals(0); if(c && equalsZero) { if(l === 0) break; this.coeffs.pop(); } else break; } return this; }
[ "function", "(", ")", "{", "var", "l", "=", "this", ".", "coeffs", ".", "length", ";", "while", "(", "l", "--", ")", "{", "var", "c", "=", "this", ".", "coeffs", "[", "l", "]", ";", "var", "equalsZero", "=", "c", ".", "equals", "(", "0", ")",...
Removes higher order zeros or a specific coefficient @returns {Array}
[ "Removes", "higher", "order", "zeros", "or", "a", "specific", "coefficient" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L154-L167
14,857
jiggzson/nerdamer
Algebra.js
function(poly) { var l = Math.max(this.coeffs.length, poly.coeffs.length); for(var i=0; i<l; i++) { var a = (this.coeffs[i] || new Frac(0)), b = (poly.coeffs[i] || new Frac(0)); this.coeffs[i] = a.add(b); } return this; }
javascript
function(poly) { var l = Math.max(this.coeffs.length, poly.coeffs.length); for(var i=0; i<l; i++) { var a = (this.coeffs[i] || new Frac(0)), b = (poly.coeffs[i] || new Frac(0)); this.coeffs[i] = a.add(b); } return this; }
[ "function", "(", "poly", ")", "{", "var", "l", "=", "Math", ".", "max", "(", "this", ".", "coeffs", ".", "length", ",", "poly", ".", "coeffs", ".", "length", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")...
Adds together 2 polynomials @param {Polynomial} poly
[ "Adds", "together", "2", "polynomials" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L212-L220
14,858
jiggzson/nerdamer
Algebra.js
function() { var l = this.coeffs.length; for(var i=0; i<l; i++) { var e = this.coeffs[i]; if(!e.equals(0)) return false; } return true; }
javascript
function() { var l = this.coeffs.length; for(var i=0; i<l; i++) { var e = this.coeffs[i]; if(!e.equals(0)) return false; } return true; }
[ "function", "(", ")", "{", "var", "l", "=", "this", ".", "coeffs", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "e", "=", "this", ".", "coeffs", "[", "i", "]", ";", "if", "(", ...
Checks if a polynomial is zero @returns {Boolean}
[ "Checks", "if", "a", "polynomial", "is", "zero" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L284-L291
14,859
jiggzson/nerdamer
Algebra.js
function() { var lc = this.lc(), l = this.coeffs.length; for(var i=0; i<l; i++) this.coeffs[i] = this.coeffs[i].divide(lc); return this; }
javascript
function() { var lc = this.lc(), l = this.coeffs.length; for(var i=0; i<l; i++) this.coeffs[i] = this.coeffs[i].divide(lc); return this; }
[ "function", "(", ")", "{", "var", "lc", "=", "this", ".", "lc", "(", ")", ",", "l", "=", "this", ".", "coeffs", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "this", ".", "coeffs", "[", "i"...
Converts polynomial into a monic polynomial @returns {Polynomial}
[ "Converts", "polynomial", "into", "a", "monic", "polynomial" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L334-L338
14,860
jiggzson/nerdamer
Algebra.js
function(poly) { //get the maximum power of each var mp1 = this.coeffs.length-1, mp2 = poly.coeffs.length-1, T; //swap so we always have the greater power first if(mp1 < mp2) { return poly.gcd(this); } var a = this; while(!poly.isZero()) { var t = poly.clone(); a = a.clone(); T = a.divide(t); poly = T[1]; a = t; } var gcd = core.Math2.QGCD.apply(null, a.coeffs); if(!gcd.equals(1)) { var l = a.coeffs.length; for(var i=0; i<l; i++) { a.coeffs[i] = a.coeffs[i].divide(gcd); } } return a; }
javascript
function(poly) { //get the maximum power of each var mp1 = this.coeffs.length-1, mp2 = poly.coeffs.length-1, T; //swap so we always have the greater power first if(mp1 < mp2) { return poly.gcd(this); } var a = this; while(!poly.isZero()) { var t = poly.clone(); a = a.clone(); T = a.divide(t); poly = T[1]; a = t; } var gcd = core.Math2.QGCD.apply(null, a.coeffs); if(!gcd.equals(1)) { var l = a.coeffs.length; for(var i=0; i<l; i++) { a.coeffs[i] = a.coeffs[i].divide(gcd); } } return a; }
[ "function", "(", "poly", ")", "{", "//get the maximum power of each\r", "var", "mp1", "=", "this", ".", "coeffs", ".", "length", "-", "1", ",", "mp2", "=", "poly", ".", "coeffs", ".", "length", "-", "1", ",", "T", ";", "//swap so we always have the greater p...
Returns the GCD of two polynomials @param {Polynomial} poly @returns {Polynomial}
[ "Returns", "the", "GCD", "of", "two", "polynomials" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L344-L371
14,861
jiggzson/nerdamer
Algebra.js
function() { var new_array = [], l = this.coeffs.length; for(var i=1; i<l; i++) new_array.push(this.coeffs[i].multiply(new Frac(i))); this.coeffs = new_array; return this; }
javascript
function() { var new_array = [], l = this.coeffs.length; for(var i=1; i<l; i++) new_array.push(this.coeffs[i].multiply(new Frac(i))); this.coeffs = new_array; return this; }
[ "function", "(", ")", "{", "var", "new_array", "=", "[", "]", ",", "l", "=", "this", ".", "coeffs", ".", "length", ";", "for", "(", "var", "i", "=", "1", ";", "i", "<", "l", ";", "i", "++", ")", "new_array", ".", "push", "(", "this", ".", "...
Differentiates the polynomial @returns {Polynomial}
[ "Differentiates", "the", "polynomial" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L376-L381
14,862
jiggzson/nerdamer
Algebra.js
function() { var new_array = [0], l = this.coeffs.length; for(var i=0; i<l; i++) { var c = new Frac(i+1); new_array[c] = this.coeffs[i].divide(c); } this.coeffs = new_array; return this; }
javascript
function() { var new_array = [0], l = this.coeffs.length; for(var i=0; i<l; i++) { var c = new Frac(i+1); new_array[c] = this.coeffs[i].divide(c); } this.coeffs = new_array; return this; }
[ "function", "(", ")", "{", "var", "new_array", "=", "[", "0", "]", ",", "l", "=", "this", ".", "coeffs", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "c", "=", "new", "Frac", "...
Integrates the polynomial @returns {Polynomial}
[ "Integrates", "the", "polynomial" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L386-L394
14,863
jiggzson/nerdamer
Algebra.js
function(toPolynomial) { //get the first nozero coefficient and returns its power var fnz = function(a) { for(var i=0; i<a.length; i++) if(!a[i].equals(0)) return i; }, ca = []; for(var i=0; i<this.coeffs.length; i++) { var c = this.coeffs[i]; if(!c.equals(0) && ca.indexOf(c) === -1) ca.push(c); } var p = [core.Math2.QGCD.apply(undefined, ca), fnz(this.coeffs)].toDecimal(); if(toPolynomial) { var parr = []; parr[p[1]-1] = p[0]; p = Polynomial.fromArray(parr, this.variable).fill(); } return p; }
javascript
function(toPolynomial) { //get the first nozero coefficient and returns its power var fnz = function(a) { for(var i=0; i<a.length; i++) if(!a[i].equals(0)) return i; }, ca = []; for(var i=0; i<this.coeffs.length; i++) { var c = this.coeffs[i]; if(!c.equals(0) && ca.indexOf(c) === -1) ca.push(c); } var p = [core.Math2.QGCD.apply(undefined, ca), fnz(this.coeffs)].toDecimal(); if(toPolynomial) { var parr = []; parr[p[1]-1] = p[0]; p = Polynomial.fromArray(parr, this.variable).fill(); } return p; }
[ "function", "(", "toPolynomial", ")", "{", "//get the first nozero coefficient and returns its power\r", "var", "fnz", "=", "function", "(", "a", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "a", ".", "length", ";", "i", "++", ")", "if", "(...
Returns the Greatest common factor of the polynomial @param {bool} toPolynomial - true if a polynomial is wanted @returns {Frac|Polynomial}
[ "Returns", "the", "Greatest", "common", "factor", "of", "the", "polynomial" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L400-L420
14,864
jiggzson/nerdamer
Algebra.js
function(a) { for(var i=0; i<a.length; i++) if(!a[i].equals(0)) return i; }
javascript
function(a) { for(var i=0; i<a.length; i++) if(!a[i].equals(0)) return i; }
[ "function", "(", "a", ")", "{", "for", "(", "var", "i", "=", "0", ";", "i", "<", "a", ".", "length", ";", "i", "++", ")", "if", "(", "!", "a", "[", "i", "]", ".", "equals", "(", "0", ")", ")", "return", "i", ";", "}" ]
get the first nozero coefficient and returns its power
[ "get", "the", "first", "nozero", "coefficient", "and", "returns", "its", "power" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L402-L405
14,865
jiggzson/nerdamer
Algebra.js
function() { var a = this.clone(), i = 1, b = a.clone().diff(), c = a.clone().gcd(b), w = a.divide(c)[0]; var output = Polynomial.fromArray([new Frac(1)], a.variable); while(!c.equalsNumber(1)) { var y = w.gcd(c); var z = w.divide(y)[0]; //one of the factors may have shown up since it's square but smaller than the //one where finding if(!z.equalsNumber(1) && i>1) { var t = z.clone(); for(var j=1; j<i; j++) t.multiply(z.clone()); z = t; } output = output.multiply(z); i++; w = y; c = c.divide(y)[0]; } return [output, w, i]; }
javascript
function() { var a = this.clone(), i = 1, b = a.clone().diff(), c = a.clone().gcd(b), w = a.divide(c)[0]; var output = Polynomial.fromArray([new Frac(1)], a.variable); while(!c.equalsNumber(1)) { var y = w.gcd(c); var z = w.divide(y)[0]; //one of the factors may have shown up since it's square but smaller than the //one where finding if(!z.equalsNumber(1) && i>1) { var t = z.clone(); for(var j=1; j<i; j++) t.multiply(z.clone()); z = t; } output = output.multiply(z); i++; w = y; c = c.divide(y)[0]; } return [output, w, i]; }
[ "function", "(", ")", "{", "var", "a", "=", "this", ".", "clone", "(", ")", ",", "i", "=", "1", ",", "b", "=", "a", ".", "clone", "(", ")", ".", "diff", "(", ")", ",", "c", "=", "a", ".", "clone", "(", ")", ".", "gcd", "(", "b", ")", ...
Makes polynomial square free @returns {Array}
[ "Makes", "polynomial", "square", "free" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L442-L466
14,866
jiggzson/nerdamer
Algebra.js
function() { var l = this.coeffs.length, variable = this.variable; if(l === 0) return new core.Symbol(0); var end = l -1, str = ''; for(var i=0; i<l; i++) { //place the plus sign for all but the last one var plus = i === end ? '' : '+', e = this.coeffs[i]; if(!e.equals(0)) str += (e+'*'+variable+'^'+i+plus); } return _.parse(str); }
javascript
function() { var l = this.coeffs.length, variable = this.variable; if(l === 0) return new core.Symbol(0); var end = l -1, str = ''; for(var i=0; i<l; i++) { //place the plus sign for all but the last one var plus = i === end ? '' : '+', e = this.coeffs[i]; if(!e.equals(0)) str += (e+'*'+variable+'^'+i+plus); } return _.parse(str); }
[ "function", "(", ")", "{", "var", "l", "=", "this", ".", "coeffs", ".", "length", ",", "variable", "=", "this", ".", "variable", ";", "if", "(", "l", "===", "0", ")", "return", "new", "core", ".", "Symbol", "(", "0", ")", ";", "var", "end", "="...
Converts polynomial to Symbol @returns {Symbol}
[ "Converts", "polynomial", "to", "Symbol" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L471-L484
14,867
jiggzson/nerdamer
Algebra.js
MVTerm
function MVTerm(coeff, terms, map) { this.terms = terms || []; this.coeff = coeff; this.map = map; //careful! all maps are the same object this.sum = new core.Frac(0); this.image = undefined; }
javascript
function MVTerm(coeff, terms, map) { this.terms = terms || []; this.coeff = coeff; this.map = map; //careful! all maps are the same object this.sum = new core.Frac(0); this.image = undefined; }
[ "function", "MVTerm", "(", "coeff", ",", "terms", ",", "map", ")", "{", "this", ".", "terms", "=", "terms", "||", "[", "]", ";", "this", ".", "coeff", "=", "coeff", ";", "this", ".", "map", "=", "map", ";", "//careful! all maps are the same object\r", ...
a wrapper for performing multivariate division
[ "a", "wrapper", "for", "performing", "multivariate", "division" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L732-L738
14,868
jiggzson/nerdamer
Algebra.js
function(symbol, factors) { if(symbol.isConstant() || symbol.group === S) return symbol; var poly = new Polynomial(symbol); var sqfr = poly.squareFree(); var p = sqfr[2]; //if we found a square then the p entry in the array will be non-unit if(p !== 1) { //make sure the remainder doesn't have factors var t = sqfr[1].toSymbol(); t.power = t.power.multiply(new Frac(p)); //send the factor to be fatored to be sure it's completely factored factors.add(__.Factor.factor(t)); return __.Factor.squareFree(sqfr[0].toSymbol(), factors); } return symbol; }
javascript
function(symbol, factors) { if(symbol.isConstant() || symbol.group === S) return symbol; var poly = new Polynomial(symbol); var sqfr = poly.squareFree(); var p = sqfr[2]; //if we found a square then the p entry in the array will be non-unit if(p !== 1) { //make sure the remainder doesn't have factors var t = sqfr[1].toSymbol(); t.power = t.power.multiply(new Frac(p)); //send the factor to be fatored to be sure it's completely factored factors.add(__.Factor.factor(t)); return __.Factor.squareFree(sqfr[0].toSymbol(), factors); } return symbol; }
[ "function", "(", "symbol", ",", "factors", ")", "{", "if", "(", "symbol", ".", "isConstant", "(", ")", "||", "symbol", ".", "group", "===", "S", ")", "return", "symbol", ";", "var", "poly", "=", "new", "Polynomial", "(", "symbol", ")", ";", "var", ...
Makes Symbol square free @param {Symbol} symbol @param {Factors} factors @returns {[Symbol, Factor]}
[ "Makes", "Symbol", "square", "free" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2215-L2230
14,869
jiggzson/nerdamer
Algebra.js
function(symbol, factors) { if(symbol.group !== PL) return symbol; //only PL need apply var d = core.Utils.arrayMin(keys(symbol.symbols)); var retval = new Symbol(0); var q = _.parse(symbol.value+'^'+d); symbol.each(function(x) { x = _.divide(x, q.clone()); retval = _.add(retval, x); }); factors.add(q); return retval; }
javascript
function(symbol, factors) { if(symbol.group !== PL) return symbol; //only PL need apply var d = core.Utils.arrayMin(keys(symbol.symbols)); var retval = new Symbol(0); var q = _.parse(symbol.value+'^'+d); symbol.each(function(x) { x = _.divide(x, q.clone()); retval = _.add(retval, x); }); factors.add(q); return retval; }
[ "function", "(", "symbol", ",", "factors", ")", "{", "if", "(", "symbol", ".", "group", "!==", "PL", ")", "return", "symbol", ";", "//only PL need apply\r", "var", "d", "=", "core", ".", "Utils", ".", "arrayMin", "(", "keys", "(", "symbol", ".", "symbo...
Factors the powers such that the lowest power is a constant @param {Symbol} symbol @param {Factors} factors @returns {[Symbol, Factor]}
[ "Factors", "the", "powers", "such", "that", "the", "lowest", "power", "is", "a", "constant" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2237-L2248
14,870
jiggzson/nerdamer
Algebra.js
function(symbol, factors) { if(symbol.isComposite()) { var gcd = core.Math2.QGCD.apply(null, symbol.coeffs()); if(!gcd.equals(1)) { symbol.each(function(x) { if(x.isComposite()) { x.each(function(y){ y.multiplier = y.multiplier.divide(gcd); }); } else x.multiplier = x.multiplier.divide(gcd); }); } symbol.updateHash(); if(factors) factors.add(new Symbol(gcd)); } return symbol; }
javascript
function(symbol, factors) { if(symbol.isComposite()) { var gcd = core.Math2.QGCD.apply(null, symbol.coeffs()); if(!gcd.equals(1)) { symbol.each(function(x) { if(x.isComposite()) { x.each(function(y){ y.multiplier = y.multiplier.divide(gcd); }); } else x.multiplier = x.multiplier.divide(gcd); }); } symbol.updateHash(); if(factors) factors.add(new Symbol(gcd)); } return symbol; }
[ "function", "(", "symbol", ",", "factors", ")", "{", "if", "(", "symbol", ".", "isComposite", "(", ")", ")", "{", "var", "gcd", "=", "core", ".", "Math2", ".", "QGCD", ".", "apply", "(", "null", ",", "symbol", ".", "coeffs", "(", ")", ")", ";", ...
Removes GCD from coefficients @param {Symbol} symbol @param {Factor} factors @returns {Symbol}
[ "Removes", "GCD", "from", "coefficients" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2255-L2273
14,871
jiggzson/nerdamer
Algebra.js
function(c1, c2, n, p) { var candidate = Polynomial.fit(c1, c2, n, base, p, v); if(candidate && candidate.coeffs.length > 1) { var t = poly.divide(candidate); if(t[1].equalsNumber(0)) { factors.add(candidate.toSymbol()); return [t[0], candidate]; } } return null; }
javascript
function(c1, c2, n, p) { var candidate = Polynomial.fit(c1, c2, n, base, p, v); if(candidate && candidate.coeffs.length > 1) { var t = poly.divide(candidate); if(t[1].equalsNumber(0)) { factors.add(candidate.toSymbol()); return [t[0], candidate]; } } return null; }
[ "function", "(", "c1", ",", "c2", ",", "n", ",", "p", ")", "{", "var", "candidate", "=", "Polynomial", ".", "fit", "(", "c1", ",", "c2", ",", "n", ",", "base", ",", "p", ",", "v", ")", ";", "if", "(", "candidate", "&&", "candidate", ".", "coe...
the polynmial variable name Attempt to remove a root by division given a number by first creating a polynomial fromt he given information @param {int} c1 - coeffient for the constant @param {int} c2 - coefficient for the LT @param {int} n - the number to be used to construct the polynomial @param {int} p - the power at which to create the polynomial @returns {null|Polynomial} - returns polynomial if successful otherwise null
[ "the", "polynmial", "variable", "name", "Attempt", "to", "remove", "a", "root", "by", "division", "given", "a", "number", "by", "first", "creating", "a", "polynomial", "fromt", "he", "given", "information" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2327-L2337
14,872
jiggzson/nerdamer
Algebra.js
function(symbol, factors) { if(symbol.group !== FN) { var vars = variables(symbol).reverse(); for(var i=0; i<vars.length; i++) { do { if(vars[i] === symbol.value){ //the derivative tells us nothing since this symbol is already the factor factors.add(symbol); symbol = new Symbol(1); continue; } var d = __.Factor.coeffFactor(core.Calculus.diff(symbol, vars[i])); if(d.equals(0)) break; var div = __.div(symbol, d.clone()), is_factor = div[1].equals(0); if(div[0].isConstant()) { factors.add(div[0]); break; } if(is_factor) { factors.add(div[0]); symbol = d; } } while(is_factor) } } return symbol; }
javascript
function(symbol, factors) { if(symbol.group !== FN) { var vars = variables(symbol).reverse(); for(var i=0; i<vars.length; i++) { do { if(vars[i] === symbol.value){ //the derivative tells us nothing since this symbol is already the factor factors.add(symbol); symbol = new Symbol(1); continue; } var d = __.Factor.coeffFactor(core.Calculus.diff(symbol, vars[i])); if(d.equals(0)) break; var div = __.div(symbol, d.clone()), is_factor = div[1].equals(0); if(div[0].isConstant()) { factors.add(div[0]); break; } if(is_factor) { factors.add(div[0]); symbol = d; } } while(is_factor) } } return symbol; }
[ "function", "(", "symbol", ",", "factors", ")", "{", "if", "(", "symbol", ".", "group", "!==", "FN", ")", "{", "var", "vars", "=", "variables", "(", "symbol", ")", ".", "reverse", "(", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", ...
Equivalent of square free factor for multivariate polynomials @param {type} symbol @param {type} factors @returns {AlgebraL#18.Factor.mSqfrFactor.symbol|Array|AlgebraL#18.__.Factor.mSqfrFactor.d}
[ "Equivalent", "of", "square", "free", "factor", "for", "multivariate", "polynomials" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2380-L2412
14,873
jiggzson/nerdamer
Algebra.js
function(symbol, factors) { try { var remove_square = function(x) { return core.Utils.block('POSITIVE_MULTIPLIERS', function() { return Symbol.unwrapPARENS(math.sqrt(math.abs(x))); }, true); }; var separated = core.Utils.separate(symbol.clone()); var obj_array = []; //get the unique variables for(var x in separated) { if(x !== 'constants') { obj_array.push(separated[x]); } } obj_array.sort(function(a, b) { return b.power - a.power; }); //if we have the same number of variables as unique variables then we can apply the difference of squares if(obj_array.length === 2) { var a, b; a = obj_array.pop(); b = obj_array.pop(); if(a.isComposite() && b.power.equals(2)) { //remove the square from b b = remove_square(b); var f = __.Factor.factor(_.add(a, separated.constants)); if(f.power.equals(2)) { f.toLinear(); factors.add(_.subtract(f.clone(), b.clone())); factors.add(_.add(f, b)); symbol = new Symbol(1); } } else { a = a.powSimp(); b = b.powSimp(); if((a.group === S || a.fname === '') && a.power.equals(2) && (b.group === S || b.fname === '') && b.power.equals(2)) { if(a.multiplier.lessThan(0)) { var t = b; b = a; a = t; } if(a.multiplier.greaterThan(0)) { a = remove_square(a); b = remove_square(b); } factors.add(_.subtract(a.clone(), b.clone())); factors.add(_.add(a, b)); symbol = new Symbol(1); } } } } catch(e){;} return symbol; }
javascript
function(symbol, factors) { try { var remove_square = function(x) { return core.Utils.block('POSITIVE_MULTIPLIERS', function() { return Symbol.unwrapPARENS(math.sqrt(math.abs(x))); }, true); }; var separated = core.Utils.separate(symbol.clone()); var obj_array = []; //get the unique variables for(var x in separated) { if(x !== 'constants') { obj_array.push(separated[x]); } } obj_array.sort(function(a, b) { return b.power - a.power; }); //if we have the same number of variables as unique variables then we can apply the difference of squares if(obj_array.length === 2) { var a, b; a = obj_array.pop(); b = obj_array.pop(); if(a.isComposite() && b.power.equals(2)) { //remove the square from b b = remove_square(b); var f = __.Factor.factor(_.add(a, separated.constants)); if(f.power.equals(2)) { f.toLinear(); factors.add(_.subtract(f.clone(), b.clone())); factors.add(_.add(f, b)); symbol = new Symbol(1); } } else { a = a.powSimp(); b = b.powSimp(); if((a.group === S || a.fname === '') && a.power.equals(2) && (b.group === S || b.fname === '') && b.power.equals(2)) { if(a.multiplier.lessThan(0)) { var t = b; b = a; a = t; } if(a.multiplier.greaterThan(0)) { a = remove_square(a); b = remove_square(b); } factors.add(_.subtract(a.clone(), b.clone())); factors.add(_.add(a, b)); symbol = new Symbol(1); } } } } catch(e){;} return symbol; }
[ "function", "(", "symbol", ",", "factors", ")", "{", "try", "{", "var", "remove_square", "=", "function", "(", "x", ")", "{", "return", "core", ".", "Utils", ".", "block", "(", "'POSITIVE_MULTIPLIERS'", ",", "function", "(", ")", "{", "return", "Symbol",...
difference of squares factorization
[ "difference", "of", "squares", "factorization" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2414-L2471
14,874
jiggzson/nerdamer
Algebra.js
function(set) { var l = set.length; for(var i=0; i<l; i++) if(!__.isLinear(set[i])) return false; return true; }
javascript
function(set) { var l = set.length; for(var i=0; i<l; i++) if(!__.isLinear(set[i])) return false; return true; }
[ "function", "(", "set", ")", "{", "var", "l", "=", "set", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "if", "(", "!", "__", ".", "isLinear", "(", "set", "[", "i", "]", ")", ")", "return",...
Checks to see if a set of "equations" is linear. @param {type} set @returns {Boolean}
[ "Checks", "to", "see", "if", "a", "set", "of", "equations", "is", "linear", "." ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2578-L2582
14,875
jiggzson/nerdamer
Algebra.js
function(symbol1, symbol2) { var result, remainder, factored, den; factored = core.Algebra.Factor.factor(symbol1.clone()); den = factored.getDenom(); if(!den.isConstant('all')) { symbol1 = _.expand(Symbol.unwrapPARENS(_.multiply(factored, den.clone()))); } else //reset the denominator since we're not dividing by it anymore den = new Symbol(1); result = __.div(symbol1, symbol2); remainder = _.divide(result[1], symbol2); return _.divide(_.add(result[0], remainder), den); }
javascript
function(symbol1, symbol2) { var result, remainder, factored, den; factored = core.Algebra.Factor.factor(symbol1.clone()); den = factored.getDenom(); if(!den.isConstant('all')) { symbol1 = _.expand(Symbol.unwrapPARENS(_.multiply(factored, den.clone()))); } else //reset the denominator since we're not dividing by it anymore den = new Symbol(1); result = __.div(symbol1, symbol2); remainder = _.divide(result[1], symbol2); return _.divide(_.add(result[0], remainder), den); }
[ "function", "(", "symbol1", ",", "symbol2", ")", "{", "var", "result", ",", "remainder", ",", "factored", ",", "den", ";", "factored", "=", "core", ".", "Algebra", ".", "Factor", ".", "factor", "(", "symbol1", ".", "clone", "(", ")", ")", ";", "den",...
Divides one expression by another @param {Symbol} symbol1 @param {Symbol} symbol2 @returns {Array}
[ "Divides", "one", "expression", "by", "another" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2797-L2810
14,876
jiggzson/nerdamer
Algebra.js
function(arr) { var symbol = new Symbol(0); for(var i=0; i<arr.length; i++) { var x = arr[i].toSymbol(); symbol = _.add(symbol, x); } return symbol; }
javascript
function(arr) { var symbol = new Symbol(0); for(var i=0; i<arr.length; i++) { var x = arr[i].toSymbol(); symbol = _.add(symbol, x); } return symbol; }
[ "function", "(", "arr", ")", "{", "var", "symbol", "=", "new", "Symbol", "(", "0", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "arr", ".", "length", ";", "i", "++", ")", "{", "var", "x", "=", "arr", "[", "i", "]", ".", "toS...
this is for the numbers
[ "this", "is", "for", "the", "numbers" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2859-L2866
14,877
jiggzson/nerdamer
Algebra.js
function(term, any) { var max = Math.max.apply(null, term.terms), count = 0, idx; if(!any) { for(var i=0; i<term.terms.length; i++) { if(term.terms[i].equals(max)) { idx = i; count++; } if(count > 1) return; } } if(any) { for(i=0; i<term.terms.length; i++) if(term.terms[i].equals(max)) { idx = i; break; } } return [max, idx, term]; }
javascript
function(term, any) { var max = Math.max.apply(null, term.terms), count = 0, idx; if(!any) { for(var i=0; i<term.terms.length; i++) { if(term.terms[i].equals(max)) { idx = i; count++; } if(count > 1) return; } } if(any) { for(i=0; i<term.terms.length; i++) if(term.terms[i].equals(max)) { idx = i; break; } } return [max, idx, term]; }
[ "function", "(", "term", ",", "any", ")", "{", "var", "max", "=", "Math", ".", "max", ".", "apply", "(", "null", ",", "term", ".", "terms", ")", ",", "count", "=", "0", ",", "idx", ";", "if", "(", "!", "any", ")", "{", "for", "(", "var", "i...
Silly Martin. This is why you document. I don't remember now
[ "Silly", "Martin", ".", "This", "is", "why", "you", "document", ".", "I", "don", "t", "remember", "now" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2868-L2887
14,878
jiggzson/nerdamer
Algebra.js
function(s, lookat) { lookat = lookat || 0; var det = s[lookat], l = s.length; if(!det) return; //eliminate the first term if it doesn't apply var umax = get_unique_max(det); for(var i=lookat+1; i<l; i++) { var term = s[i], is_equal = det.sum.equals(term.sum); if(!is_equal && umax) { break; } if(is_equal) { //check the differences of their maxes. The one with the biggest difference governs //e.g. x^2*y^3 vs x^2*y^3 is unclear but this isn't the case in x*y and x^2 var max1, max2, idx1, idx2, l2 = det.terms.length; for(var j=0; j<l2; j++) { var item1 = det.terms[j], item2 = term.terms[j]; if(typeof max1 === 'undefined' || item1.greaterThan(max1)) { max1 = item1; idx1 = j; } if(typeof max2 === 'undefined' || item2.greaterThan(max2)) { max2 = item2; idx2 = j; } } //check their differences var d1 = max1.subtract(term.terms[idx1]), d2 = max2.subtract(det.terms[idx2]); if(d2 > d1) { umax = [max2, idx2, term]; break; } if(d1 > d2) { umax = [max1, idx1, det]; break; } } else { //check if it's a suitable pick to determine the order umax = get_unique_max(term); //if(umax) return umax; if(umax) break; } umax = get_unique_max(term); //calculate a new unique max } //if still no umax then any will do since we have a tie if(!umax) return get_unique_max(s[0], true); var e, idx; for(var i=0; i<s2.length; i++) { var cterm = s2[i].terms; //confirm that this is a good match for the denominator idx = umax[1]; if(idx === cterm.length - 1) return ; e = cterm[idx]; if(!e.equals(0)) break; } if(e.equals(0)) return get_det(s, ++lookat); //look at the next term return umax; }
javascript
function(s, lookat) { lookat = lookat || 0; var det = s[lookat], l = s.length; if(!det) return; //eliminate the first term if it doesn't apply var umax = get_unique_max(det); for(var i=lookat+1; i<l; i++) { var term = s[i], is_equal = det.sum.equals(term.sum); if(!is_equal && umax) { break; } if(is_equal) { //check the differences of their maxes. The one with the biggest difference governs //e.g. x^2*y^3 vs x^2*y^3 is unclear but this isn't the case in x*y and x^2 var max1, max2, idx1, idx2, l2 = det.terms.length; for(var j=0; j<l2; j++) { var item1 = det.terms[j], item2 = term.terms[j]; if(typeof max1 === 'undefined' || item1.greaterThan(max1)) { max1 = item1; idx1 = j; } if(typeof max2 === 'undefined' || item2.greaterThan(max2)) { max2 = item2; idx2 = j; } } //check their differences var d1 = max1.subtract(term.terms[idx1]), d2 = max2.subtract(det.terms[idx2]); if(d2 > d1) { umax = [max2, idx2, term]; break; } if(d1 > d2) { umax = [max1, idx1, det]; break; } } else { //check if it's a suitable pick to determine the order umax = get_unique_max(term); //if(umax) return umax; if(umax) break; } umax = get_unique_max(term); //calculate a new unique max } //if still no umax then any will do since we have a tie if(!umax) return get_unique_max(s[0], true); var e, idx; for(var i=0; i<s2.length; i++) { var cterm = s2[i].terms; //confirm that this is a good match for the denominator idx = umax[1]; if(idx === cterm.length - 1) return ; e = cterm[idx]; if(!e.equals(0)) break; } if(e.equals(0)) return get_det(s, ++lookat); //look at the next term return umax; }
[ "function", "(", "s", ",", "lookat", ")", "{", "lookat", "=", "lookat", "||", "0", ";", "var", "det", "=", "s", "[", "lookat", "]", ",", "l", "=", "s", ".", "length", ";", "if", "(", "!", "det", ")", "return", ";", "//eliminate the first term if it...
tries to find an LT in the dividend that will satisfy division
[ "tries", "to", "find", "an", "LT", "in", "the", "dividend", "that", "will", "satisfy", "division" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L2889-L2949
14,879
jiggzson/nerdamer
Algebra.js
function(symbol, v, raw) { if(!core.Utils.isSymbol(v)) v = _.parse(v); var stop = function(msg) { msg = msg || 'Stopping'; throw new core.exceptions.ValueLimitExceededError(msg); }; //if not CP then nothing to do if(!symbol.isPoly()) stop('Must be a polynomial!'); //declare vars var deg, a, b, c, d, e, coeffs, sign, br, sym, sqrt_a; br = core.Utils.inBrackets; //make a copy symbol = symbol.clone(); deg = core.Algebra.degree(symbol, v); //get the degree of polynomial //must be in form ax^2 +/- bx +/- c if(!deg.equals(2)) stop('Cannot complete square for degree '+deg); //get the coeffs coeffs = core.Algebra.coeffs(symbol, v); a = coeffs[2]; //store the sign sign = coeffs[1].sign(); //divide the linear term by two and square it b = _.divide(coeffs[1], new Symbol(2)); //add the difference to the constant c = _.pow(b.clone(), new Symbol(2)); if(raw) return [a, b, d]; sqrt_a = math.sqrt(a); e = _.divide(math.sqrt(c), sqrt_a.clone()); //calculate d which is the constant d = _.subtract(coeffs[0], _.pow(e.clone(), new Symbol(2))); //compute the square part sym = _.parse(br(sqrt_a.clone()+'*'+v+(sign < 0 ? '-' : '+')+e)); return { a: sym, c: d, f: _.add(_.pow(sym.clone(), new Symbol(2)), d.clone()) }; }
javascript
function(symbol, v, raw) { if(!core.Utils.isSymbol(v)) v = _.parse(v); var stop = function(msg) { msg = msg || 'Stopping'; throw new core.exceptions.ValueLimitExceededError(msg); }; //if not CP then nothing to do if(!symbol.isPoly()) stop('Must be a polynomial!'); //declare vars var deg, a, b, c, d, e, coeffs, sign, br, sym, sqrt_a; br = core.Utils.inBrackets; //make a copy symbol = symbol.clone(); deg = core.Algebra.degree(symbol, v); //get the degree of polynomial //must be in form ax^2 +/- bx +/- c if(!deg.equals(2)) stop('Cannot complete square for degree '+deg); //get the coeffs coeffs = core.Algebra.coeffs(symbol, v); a = coeffs[2]; //store the sign sign = coeffs[1].sign(); //divide the linear term by two and square it b = _.divide(coeffs[1], new Symbol(2)); //add the difference to the constant c = _.pow(b.clone(), new Symbol(2)); if(raw) return [a, b, d]; sqrt_a = math.sqrt(a); e = _.divide(math.sqrt(c), sqrt_a.clone()); //calculate d which is the constant d = _.subtract(coeffs[0], _.pow(e.clone(), new Symbol(2))); //compute the square part sym = _.parse(br(sqrt_a.clone()+'*'+v+(sign < 0 ? '-' : '+')+e)); return { a: sym, c: d, f: _.add(_.pow(sym.clone(), new Symbol(2)), d.clone()) }; }
[ "function", "(", "symbol", ",", "v", ",", "raw", ")", "{", "if", "(", "!", "core", ".", "Utils", ".", "isSymbol", "(", "v", ")", ")", "v", "=", "_", ".", "parse", "(", "v", ")", ";", "var", "stop", "=", "function", "(", "msg", ")", "{", "ms...
Attempts to complete the square of a polynomial @param {type} symbol @param {type} v @param {type} raw @throws {Error} @returns {Object|Symbol[]}
[ "Attempts", "to", "complete", "the", "square", "of", "a", "polynomial" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Algebra.js#L3332-L3374
14,880
jiggzson/nerdamer
Solve.js
function(eqn) { //If it's an equation then call its toLHS function instead if(eqn instanceof Equation) return eqn.toLHS(); var es = eqn.split('='); if(es[1] === undefined) es[1] = '0'; var e1 = _.parse(es[0]), e2 = _.parse(es[1]); return removeDenom(e1, e2); }
javascript
function(eqn) { //If it's an equation then call its toLHS function instead if(eqn instanceof Equation) return eqn.toLHS(); var es = eqn.split('='); if(es[1] === undefined) es[1] = '0'; var e1 = _.parse(es[0]), e2 = _.parse(es[1]); return removeDenom(e1, e2); }
[ "function", "(", "eqn", ")", "{", "//If it's an equation then call its toLHS function instead\r", "if", "(", "eqn", "instanceof", "Equation", ")", "return", "eqn", ".", "toLHS", "(", ")", ";", "var", "es", "=", "eqn", ".", "split", "(", "'='", ")", ";", "if"...
A utility function to parse an expression to left hand side when working with strings
[ "A", "utility", "function", "to", "parse", "an", "expression", "to", "left", "hand", "side", "when", "working", "with", "strings" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Solve.js#L154-L162
14,881
jiggzson/nerdamer
Solve.js
function(c, b, a, plus_or_min) { var plus_or_minus = plus_or_min === '-' ? 'subtract': 'add'; var bsqmin4ac = _.subtract(_.pow(b.clone(), Symbol(2)), _.multiply(_.multiply(a.clone(), c.clone()),Symbol(4)))/*b^2 - 4ac*/; var det = _.pow(bsqmin4ac, Symbol(0.5)); var retval = _.divide(_[plus_or_minus](b.clone().negate(), det),_.multiply(new Symbol(2), a.clone())); return retval; }
javascript
function(c, b, a, plus_or_min) { var plus_or_minus = plus_or_min === '-' ? 'subtract': 'add'; var bsqmin4ac = _.subtract(_.pow(b.clone(), Symbol(2)), _.multiply(_.multiply(a.clone(), c.clone()),Symbol(4)))/*b^2 - 4ac*/; var det = _.pow(bsqmin4ac, Symbol(0.5)); var retval = _.divide(_[plus_or_minus](b.clone().negate(), det),_.multiply(new Symbol(2), a.clone())); return retval; }
[ "function", "(", "c", ",", "b", ",", "a", ",", "plus_or_min", ")", "{", "var", "plus_or_minus", "=", "plus_or_min", "===", "'-'", "?", "'subtract'", ":", "'add'", ";", "var", "bsqmin4ac", "=", "_", ".", "subtract", "(", "_", ".", "pow", "(", "b", "...
solve quad oder polynomials symbolically
[ "solve", "quad", "oder", "polynomials", "symbolically" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Solve.js#L279-L285
14,882
jiggzson/nerdamer
Solve.js
function(symbol, solve_for) { var sols = []; //see if we can solve the factors var factors = core.Algebra.Factor.factor(symbol); if(factors.group === CB) { factors.each(function(x) { x = Symbol.unwrapPARENS(x); sols = sols.concat(solve(x, solve_for)); }); } return sols; }
javascript
function(symbol, solve_for) { var sols = []; //see if we can solve the factors var factors = core.Algebra.Factor.factor(symbol); if(factors.group === CB) { factors.each(function(x) { x = Symbol.unwrapPARENS(x); sols = sols.concat(solve(x, solve_for)); }); } return sols; }
[ "function", "(", "symbol", ",", "solve_for", ")", "{", "var", "sols", "=", "[", "]", ";", "//see if we can solve the factors\r", "var", "factors", "=", "core", ".", "Algebra", ".", "Factor", ".", "factor", "(", "symbol", ")", ";", "if", "(", "factors", "...
solve by divide and conquer
[ "solve", "by", "divide", "and", "conquer" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Solve.js#L353-L364
14,883
jiggzson/nerdamer
Solve.js
function(point, f, fp) { var maxiter = 200, iter = 0; //first try the point itself. If it's zero viola. We're done var x0 = point, x; do { var fx0 = f(x0); //store the result of the function //if the value is zero then we're done because 0 - (0/d f(x0)) = 0 if(x0 === 0 && fx0 === 0) { x = 0; break; } iter++; if(iter > maxiter) return; //naximum iterations reached x = x0 - fx0/fp(x0); var e = Math.abs(x - x0); x0 = x; } while(e > Number.EPSILON) return x; }
javascript
function(point, f, fp) { var maxiter = 200, iter = 0; //first try the point itself. If it's zero viola. We're done var x0 = point, x; do { var fx0 = f(x0); //store the result of the function //if the value is zero then we're done because 0 - (0/d f(x0)) = 0 if(x0 === 0 && fx0 === 0) { x = 0; break; } iter++; if(iter > maxiter) return; //naximum iterations reached x = x0 - fx0/fp(x0); var e = Math.abs(x - x0); x0 = x; } while(e > Number.EPSILON) return x; }
[ "function", "(", "point", ",", "f", ",", "fp", ")", "{", "var", "maxiter", "=", "200", ",", "iter", "=", "0", ";", "//first try the point itself. If it's zero viola. We're done\r", "var", "x0", "=", "point", ",", "x", ";", "do", "{", "var", "fx0", "=", "...
Newton's iteration
[ "Newton", "s", "iteration" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Solve.js#L449-L472
14,884
jiggzson/nerdamer
Solve.js
function(symbol) { var has_trig = symbol.hasTrig(); // we get all the points where a possible zero might exist var points1 = get_points(symbol, 0.1); var points2 = get_points(symbol, 0.05); var points3 = get_points(symbol, 0.01); var points = core.Utils.arrayUnique(points1.concat(points2).concat(points3)), l = points.length; //compile the function and the derivative of the function var f = build(symbol.clone()), fp = build(_C.diff(symbol.clone())); for(var i=0; i<l; i++) { var point = points[i]; add_to_result(Newton(point, f, fp), has_trig); } solutions.sort(); }
javascript
function(symbol) { var has_trig = symbol.hasTrig(); // we get all the points where a possible zero might exist var points1 = get_points(symbol, 0.1); var points2 = get_points(symbol, 0.05); var points3 = get_points(symbol, 0.01); var points = core.Utils.arrayUnique(points1.concat(points2).concat(points3)), l = points.length; //compile the function and the derivative of the function var f = build(symbol.clone()), fp = build(_C.diff(symbol.clone())); for(var i=0; i<l; i++) { var point = points[i]; add_to_result(Newton(point, f, fp), has_trig); } solutions.sort(); }
[ "function", "(", "symbol", ")", "{", "var", "has_trig", "=", "symbol", ".", "hasTrig", "(", ")", ";", "// we get all the points where a possible zero might exist\r", "var", "points1", "=", "get_points", "(", "symbol", ",", "0.1", ")", ";", "var", "points2", "=",...
gets points around which to solve. It does that because it builds on the principle that if the sign changes over an interval then there must be a zero on that interval
[ "gets", "points", "around", "which", "to", "solve", ".", "It", "does", "that", "because", "it", "builds", "on", "the", "principle", "that", "if", "the", "sign", "changes", "over", "an", "interval", "then", "there", "must", "be", "a", "zero", "on", "that"...
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Solve.js#L552-L568
14,885
jiggzson/nerdamer
Solve.js
function(eq) { var lhs = new Symbol(0), rhs = new Symbol(0); eq.each(function(x) { if(x.contains(solve_for, true)) lhs = _.add(lhs, x.clone()); else rhs = _.subtract(rhs, x.clone()); }); return [lhs, rhs]; }
javascript
function(eq) { var lhs = new Symbol(0), rhs = new Symbol(0); eq.each(function(x) { if(x.contains(solve_for, true)) lhs = _.add(lhs, x.clone()); else rhs = _.subtract(rhs, x.clone()); }); return [lhs, rhs]; }
[ "function", "(", "eq", ")", "{", "var", "lhs", "=", "new", "Symbol", "(", "0", ")", ",", "rhs", "=", "new", "Symbol", "(", "0", ")", ";", "eq", ".", "each", "(", "function", "(", "x", ")", "{", "if", "(", "x", ".", "contains", "(", "solve_for...
separate the equation
[ "separate", "the", "equation" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Solve.js#L692-L702
14,886
jiggzson/nerdamer
Calculus.js
polydiff
function polydiff(symbol) { if(symbol.value === d || symbol.contains(d, true)) { symbol.multiplier = symbol.multiplier.multiply(symbol.power); symbol.power = symbol.power.subtract(new Frac(1)); if(symbol.power.equals(0)) { symbol = Symbol(symbol.multiplier); } } return symbol; }
javascript
function polydiff(symbol) { if(symbol.value === d || symbol.contains(d, true)) { symbol.multiplier = symbol.multiplier.multiply(symbol.power); symbol.power = symbol.power.subtract(new Frac(1)); if(symbol.power.equals(0)) { symbol = Symbol(symbol.multiplier); } } return symbol; }
[ "function", "polydiff", "(", "symbol", ")", "{", "if", "(", "symbol", ".", "value", "===", "d", "||", "symbol", ".", "contains", "(", "d", ",", "true", ")", ")", "{", "symbol", ".", "multiplier", "=", "symbol", ".", "multiplier", ".", "multiply", "("...
Equivalent to "derivative of the outside".
[ "Equivalent", "to", "derivative", "of", "the", "outside", "." ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Calculus.js#L395-L405
14,887
jiggzson/nerdamer
Calculus.js
function(x) { var g = x.group; if(g === FN) { var fname = x.fname; if(core.Utils.in_trig(fname) || core.Utils.in_htrig(fname)) parts[3].push(x); else if(core.Utils.in_inverse_trig(fname)) parts[1].push(x); else if(fname === LOG) parts[0].push(x); else { __.integration.stop(); } } else if(g === S || x.isComposite() && x.isLinear() || g === CB && x.isLinear()) { parts[2].push(x); } else if(g === EX || x.isComposite() && !x.isLinear()) parts[4].push(x); else __.integration.stop(); }
javascript
function(x) { var g = x.group; if(g === FN) { var fname = x.fname; if(core.Utils.in_trig(fname) || core.Utils.in_htrig(fname)) parts[3].push(x); else if(core.Utils.in_inverse_trig(fname)) parts[1].push(x); else if(fname === LOG) parts[0].push(x); else { __.integration.stop(); } } else if(g === S || x.isComposite() && x.isLinear() || g === CB && x.isLinear()) { parts[2].push(x); } else if(g === EX || x.isComposite() && !x.isLinear()) parts[4].push(x); else __.integration.stop(); }
[ "function", "(", "x", ")", "{", "var", "g", "=", "x", ".", "group", ";", "if", "(", "g", "===", "FN", ")", "{", "var", "fname", "=", "x", ".", "fname", ";", "if", "(", "core", ".", "Utils", ".", "in_trig", "(", "fname", ")", "||", "core", "...
first we sort them
[ "first", "we", "sort", "them" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Calculus.js#L779-L800
14,888
jiggzson/nerdamer
Calculus.js
function(symbol) { var p = symbol.power, k = p/2, e; if(symbol.fname === COS) e = '((1/2)+(cos(2*('+symbol.args[0]+'))/2))^'+k; else e = '((1/2)-(cos(2*('+symbol.args[0]+'))/2))^'+k; return _.parse(e); }
javascript
function(symbol) { var p = symbol.power, k = p/2, e; if(symbol.fname === COS) e = '((1/2)+(cos(2*('+symbol.args[0]+'))/2))^'+k; else e = '((1/2)-(cos(2*('+symbol.args[0]+'))/2))^'+k; return _.parse(e); }
[ "function", "(", "symbol", ")", "{", "var", "p", "=", "symbol", ".", "power", ",", "k", "=", "p", "/", "2", ",", "e", ";", "if", "(", "symbol", ".", "fname", "===", "COS", ")", "e", "=", "'((1/2)+(cos(2*('", "+", "symbol", ".", "args", "[", "0"...
performs double angle transformation
[ "performs", "double", "angle", "transformation" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Calculus.js#L1529-L1538
14,889
jiggzson/nerdamer
Calculus.js
function(integral, vars, point) { try { return _.parse(integral, vars); } catch(e) { //it failed for some reason so return the limit return __.Limit.limit(integral, dx, point); } }
javascript
function(integral, vars, point) { try { return _.parse(integral, vars); } catch(e) { //it failed for some reason so return the limit return __.Limit.limit(integral, dx, point); } }
[ "function", "(", "integral", ",", "vars", ",", "point", ")", "{", "try", "{", "return", "_", ".", "parse", "(", "integral", ",", "vars", ")", ";", "}", "catch", "(", "e", ")", "{", "//it failed for some reason so return the limit\r", "return", "__", ".", ...
make x the default variable of integration
[ "make", "x", "the", "default", "variable", "of", "integration" ]
1fa6c5cbcd9b1f93f76ab68ba9d0573839801167
https://github.com/jiggzson/nerdamer/blob/1fa6c5cbcd9b1f93f76ab68ba9d0573839801167/Calculus.js#L1939-L1947
14,890
fontello/svg2ttf
lib/ttf/utils.js
interpolate
function interpolate(contours, accuracy) { return _.map(contours, function (contour) { var resContour = []; _.forEach(contour, function (point, idx) { // Never skip first and last points if (idx === 0 || idx === (contour.length - 1)) { resContour.push(point); return; } var prev = contour[idx - 1]; var next = contour[idx + 1]; var p, pPrev, pNext; // skip interpolateable oncurve points (if exactly between previous and next offcurves) if (!prev.onCurve && point.onCurve && !next.onCurve) { p = new math.Point(point.x, point.y); pPrev = new math.Point(prev.x, prev.y); pNext = new math.Point(next.x, next.y); if (pPrev.add(pNext).div(2).sub(p).dist() < accuracy) { return; } } // keep the rest resContour.push(point); }); return resContour; }); }
javascript
function interpolate(contours, accuracy) { return _.map(contours, function (contour) { var resContour = []; _.forEach(contour, function (point, idx) { // Never skip first and last points if (idx === 0 || idx === (contour.length - 1)) { resContour.push(point); return; } var prev = contour[idx - 1]; var next = contour[idx + 1]; var p, pPrev, pNext; // skip interpolateable oncurve points (if exactly between previous and next offcurves) if (!prev.onCurve && point.onCurve && !next.onCurve) { p = new math.Point(point.x, point.y); pPrev = new math.Point(prev.x, prev.y); pNext = new math.Point(next.x, next.y); if (pPrev.add(pNext).div(2).sub(p).dist() < accuracy) { return; } } // keep the rest resContour.push(point); }); return resContour; }); }
[ "function", "interpolate", "(", "contours", ",", "accuracy", ")", "{", "return", "_", ".", "map", "(", "contours", ",", "function", "(", "contour", ")", "{", "var", "resContour", "=", "[", "]", ";", "_", ".", "forEach", "(", "contour", ",", "function",...
Remove interpolateable oncurve points Those should be in the middle of nebor offcurve points
[ "Remove", "interpolateable", "oncurve", "points", "Those", "should", "be", "in", "the", "middle", "of", "nebor", "offcurve", "points" ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ttf/utils.js#L35-L65
14,891
fontello/svg2ttf
lib/ttf/utils.js
removeClosingReturnPoints
function removeClosingReturnPoints(contours) { return _.map(contours, function (contour) { var length = contour.length; if (length > 1 && contour[0].x === contour[length - 1].x && contour[0].y === contour[length - 1].y) { contour.splice(length - 1); } return contour; }); }
javascript
function removeClosingReturnPoints(contours) { return _.map(contours, function (contour) { var length = contour.length; if (length > 1 && contour[0].x === contour[length - 1].x && contour[0].y === contour[length - 1].y) { contour.splice(length - 1); } return contour; }); }
[ "function", "removeClosingReturnPoints", "(", "contours", ")", "{", "return", "_", ".", "map", "(", "contours", ",", "function", "(", "contour", ")", "{", "var", "length", "=", "contour", ".", "length", ";", "if", "(", "length", ">", "1", "&&", "contour"...
Remove closing point if it is the same as first point of contour. TTF doesn't need this point when drawing contours.
[ "Remove", "closing", "point", "if", "it", "is", "the", "same", "as", "first", "point", "of", "contour", ".", "TTF", "doesn", "t", "need", "this", "point", "when", "drawing", "contours", "." ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ttf/utils.js#L77-L88
14,892
fontello/svg2ttf
lib/ttf/tables/glyf.js
compactFlags
function compactFlags(flags) { var result = []; var prevFlag = -1; var firstRepeat = false; _.forEach(flags, function (flag) { if (prevFlag === flag) { if (firstRepeat) { result[result.length - 1] += 8; //current flag repeats previous one, need to set 3rd bit of previous flag and set 1 to the current one result.push(1); firstRepeat = false; } else { result[result.length - 1]++; //when flag is repeating second or more times, we need to increase the last flag value } } else { firstRepeat = true; prevFlag = flag; result.push(flag); } }); return result; }
javascript
function compactFlags(flags) { var result = []; var prevFlag = -1; var firstRepeat = false; _.forEach(flags, function (flag) { if (prevFlag === flag) { if (firstRepeat) { result[result.length - 1] += 8; //current flag repeats previous one, need to set 3rd bit of previous flag and set 1 to the current one result.push(1); firstRepeat = false; } else { result[result.length - 1]++; //when flag is repeating second or more times, we need to increase the last flag value } } else { firstRepeat = true; prevFlag = flag; result.push(flag); } }); return result; }
[ "function", "compactFlags", "(", "flags", ")", "{", "var", "result", "=", "[", "]", ";", "var", "prevFlag", "=", "-", "1", ";", "var", "firstRepeat", "=", "false", ";", "_", ".", "forEach", "(", "flags", ",", "function", "(", "flag", ")", "{", "if"...
repeating flags can be packed
[ "repeating", "flags", "can", "be", "packed" ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ttf/tables/glyf.js#L42-L63
14,893
fontello/svg2ttf
lib/ttf/tables/glyf.js
glyphDataSize
function glyphDataSize(glyph) { // Ignore glyphs without outlines. These will get a length of zero in the “loca” table if (!glyph.contours.length) { return 0; } var result = 12; //glyph fixed properties result += glyph.contours.length * 2; //add contours _.forEach(glyph.ttf_x, function (x) { //add 1 or 2 bytes for each coordinate depending of its size result += ((-0xFF <= x && x <= 0xFF)) ? 1 : 2; }); _.forEach(glyph.ttf_y, function (y) { //add 1 or 2 bytes for each coordinate depending of its size result += ((-0xFF <= y && y <= 0xFF)) ? 1 : 2; }); // Add flags length to glyph size. result += glyph.ttf_flags.length; if (result % 4 !== 0) { // glyph size must be divisible by 4. result += 4 - result % 4; } return result; }
javascript
function glyphDataSize(glyph) { // Ignore glyphs without outlines. These will get a length of zero in the “loca” table if (!glyph.contours.length) { return 0; } var result = 12; //glyph fixed properties result += glyph.contours.length * 2; //add contours _.forEach(glyph.ttf_x, function (x) { //add 1 or 2 bytes for each coordinate depending of its size result += ((-0xFF <= x && x <= 0xFF)) ? 1 : 2; }); _.forEach(glyph.ttf_y, function (y) { //add 1 or 2 bytes for each coordinate depending of its size result += ((-0xFF <= y && y <= 0xFF)) ? 1 : 2; }); // Add flags length to glyph size. result += glyph.ttf_flags.length; if (result % 4 !== 0) { // glyph size must be divisible by 4. result += 4 - result % 4; } return result; }
[ "function", "glyphDataSize", "(", "glyph", ")", "{", "// Ignore glyphs without outlines. These will get a length of zero in the “loca” table", "if", "(", "!", "glyph", ".", "contours", ".", "length", ")", "{", "return", "0", ";", "}", "var", "result", "=", "12", ";"...
calculates length of glyph data in GLYF table
[ "calculates", "length", "of", "glyph", "data", "in", "GLYF", "table" ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ttf/tables/glyf.js#L81-L108
14,894
fontello/svg2ttf
lib/ucs2.js
ucs2encode
function ucs2encode(array) { return _.map(array, function (value) { var output = ''; if (value > 0xFFFF) { value -= 0x10000; output += String.fromCharCode(value >>> 10 & 0x3FF | 0xD800); value = 0xDC00 | value & 0x3FF; } output += String.fromCharCode(value); return output; }).join(''); }
javascript
function ucs2encode(array) { return _.map(array, function (value) { var output = ''; if (value > 0xFFFF) { value -= 0x10000; output += String.fromCharCode(value >>> 10 & 0x3FF | 0xD800); value = 0xDC00 | value & 0x3FF; } output += String.fromCharCode(value); return output; }).join(''); }
[ "function", "ucs2encode", "(", "array", ")", "{", "return", "_", ".", "map", "(", "array", ",", "function", "(", "value", ")", "{", "var", "output", "=", "''", ";", "if", "(", "value", ">", "0xFFFF", ")", "{", "value", "-=", "0x10000", ";", "output...
Taken from the punycode library
[ "Taken", "from", "the", "punycode", "library" ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ucs2.js#L6-L18
14,895
fontello/svg2ttf
lib/svg.js
toSfntCoutours
function toSfntCoutours(svgPath) { var resContours = []; var resContour = []; svgPath.iterate(function (segment, index, x, y) { //start new contour if (index === 0 || segment[0] === 'M') { resContour = []; resContours.push(resContour); } var name = segment[0]; if (name === 'Q') { //add control point of quad spline, it is not on curve resContour.push({ x: segment[1], y: segment[2], onCurve: false }); } // add on-curve point if (name === 'H') { // vertical line has Y coordinate only, X remains the same resContour.push({ x: segment[1], y: y, onCurve: true }); } else if (name === 'V') { // horizontal line has X coordinate only, Y remains the same resContour.push({ x: x, y: segment[1], onCurve: true }); } else if (name !== 'Z') { // for all commands (except H and V) X and Y are placed in the end of the segment resContour.push({ x: segment[segment.length - 2], y: segment[segment.length - 1], onCurve: true }); } }); return resContours; }
javascript
function toSfntCoutours(svgPath) { var resContours = []; var resContour = []; svgPath.iterate(function (segment, index, x, y) { //start new contour if (index === 0 || segment[0] === 'M') { resContour = []; resContours.push(resContour); } var name = segment[0]; if (name === 'Q') { //add control point of quad spline, it is not on curve resContour.push({ x: segment[1], y: segment[2], onCurve: false }); } // add on-curve point if (name === 'H') { // vertical line has Y coordinate only, X remains the same resContour.push({ x: segment[1], y: y, onCurve: true }); } else if (name === 'V') { // horizontal line has X coordinate only, Y remains the same resContour.push({ x: x, y: segment[1], onCurve: true }); } else if (name !== 'Z') { // for all commands (except H and V) X and Y are placed in the end of the segment resContour.push({ x: segment[segment.length - 2], y: segment[segment.length - 1], onCurve: true }); } }); return resContours; }
[ "function", "toSfntCoutours", "(", "svgPath", ")", "{", "var", "resContours", "=", "[", "]", ";", "var", "resContour", "=", "[", "]", ";", "svgPath", ".", "iterate", "(", "function", "(", "segment", ",", "index", ",", "x", ",", "y", ")", "{", "//star...
Converts svg points to contours. All points must be converted to relative ones, smooth curves must be converted to generic ones before this conversion.
[ "Converts", "svg", "points", "to", "contours", ".", "All", "points", "must", "be", "converted", "to", "relative", "ones", "smooth", "curves", "must", "be", "converted", "to", "generic", "ones", "before", "this", "conversion", "." ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/svg.js#L185-L218
14,896
fontello/svg2ttf
lib/ttf/tables/gsub.js
createFeatureList
function createFeatureList() { var header = (0 + 2 // FeatureCount + 4 // FeatureTag[0] + 2 // Feature Offset[0] ); var length = (0 + header + 2 // FeatureParams[0] + 2 // LookupCount[0] + 2 // Lookup[0] LookupListIndex[0] ); var buffer = new ByteBuffer(length); // FeatureCount buffer.writeUint16(1); // FeatureTag[0] buffer.writeUint32(identifier('liga')); // Feature Offset[0] buffer.writeUint16(header); // FeatureParams[0] buffer.writeUint16(0); // LookupCount[0] buffer.writeUint16(1); // Index into lookup table. Since we only have ligatures, the index is always 0 buffer.writeUint16(0); return buffer; }
javascript
function createFeatureList() { var header = (0 + 2 // FeatureCount + 4 // FeatureTag[0] + 2 // Feature Offset[0] ); var length = (0 + header + 2 // FeatureParams[0] + 2 // LookupCount[0] + 2 // Lookup[0] LookupListIndex[0] ); var buffer = new ByteBuffer(length); // FeatureCount buffer.writeUint16(1); // FeatureTag[0] buffer.writeUint32(identifier('liga')); // Feature Offset[0] buffer.writeUint16(header); // FeatureParams[0] buffer.writeUint16(0); // LookupCount[0] buffer.writeUint16(1); // Index into lookup table. Since we only have ligatures, the index is always 0 buffer.writeUint16(0); return buffer; }
[ "function", "createFeatureList", "(", ")", "{", "var", "header", "=", "(", "0", "+", "2", "// FeatureCount", "+", "4", "// FeatureTag[0]", "+", "2", "// Feature Offset[0]", ")", ";", "var", "length", "=", "(", "0", "+", "header", "+", "2", "// FeatureParam...
Write one feature containing all ligatures
[ "Write", "one", "feature", "containing", "all", "ligatures" ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ttf/tables/gsub.js#L108-L138
14,897
fontello/svg2ttf
lib/ttf/tables/gsub.js
createLookupList
function createLookupList(font) { var ligatures = font.ligatures; var groupedLigatures = {}; // Group ligatures by first code point _.forEach(ligatures, function (ligature) { var first = ligature.unicode[0]; if (!_.has(groupedLigatures, first)) { groupedLigatures[first] = []; } groupedLigatures[first].push(ligature); }); var ligatureGroups = []; _.forEach(groupedLigatures, function (ligatures, codePoint) { codePoint = parseInt(codePoint, 10); // Order ligatures by length, descending // “Ligatures with more components must be stored ahead of those with fewer components in order to be found” // From: http://partners.adobe.com/public/developer/opentype/index_tag7.html#liga ligatures.sort(function (ligA, ligB) { return ligB.unicode.length - ligA.unicode.length; }); ligatureGroups.push({ codePoint: codePoint, ligatures: ligatures, startGlyph: font.codePoints[codePoint] }); }); ligatureGroups.sort(function (a, b) { return a.startGlyph.id - b.startGlyph.id; }); var offset = (0 + 2 // Lookup count + 2 // Lookup[0] offset ); var set = createLigatureList(font, ligatureGroups); var length = (0 + offset + set.length ); var buffer = new ByteBuffer(length); // Lookup count buffer.writeUint16(1); // Lookup[0] offset buffer.writeUint16(offset); // Lookup[0] buffer.writeBytes(set.buffer); return buffer; }
javascript
function createLookupList(font) { var ligatures = font.ligatures; var groupedLigatures = {}; // Group ligatures by first code point _.forEach(ligatures, function (ligature) { var first = ligature.unicode[0]; if (!_.has(groupedLigatures, first)) { groupedLigatures[first] = []; } groupedLigatures[first].push(ligature); }); var ligatureGroups = []; _.forEach(groupedLigatures, function (ligatures, codePoint) { codePoint = parseInt(codePoint, 10); // Order ligatures by length, descending // “Ligatures with more components must be stored ahead of those with fewer components in order to be found” // From: http://partners.adobe.com/public/developer/opentype/index_tag7.html#liga ligatures.sort(function (ligA, ligB) { return ligB.unicode.length - ligA.unicode.length; }); ligatureGroups.push({ codePoint: codePoint, ligatures: ligatures, startGlyph: font.codePoints[codePoint] }); }); ligatureGroups.sort(function (a, b) { return a.startGlyph.id - b.startGlyph.id; }); var offset = (0 + 2 // Lookup count + 2 // Lookup[0] offset ); var set = createLigatureList(font, ligatureGroups); var length = (0 + offset + set.length ); var buffer = new ByteBuffer(length); // Lookup count buffer.writeUint16(1); // Lookup[0] offset buffer.writeUint16(offset); // Lookup[0] buffer.writeBytes(set.buffer); return buffer; }
[ "function", "createLookupList", "(", "font", ")", "{", "var", "ligatures", "=", "font", ".", "ligatures", ";", "var", "groupedLigatures", "=", "{", "}", ";", "// Group ligatures by first code point", "_", ".", "forEach", "(", "ligatures", ",", "function", "(", ...
Add a lookup for each ligature
[ "Add", "a", "lookup", "for", "each", "ligature" ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ttf/tables/gsub.js#L308-L368
14,898
fontello/svg2ttf
lib/ttf/tables/maxp.js
getMaxPoints
function getMaxPoints(font) { return _.max(_.map(font.glyphs, function (glyph) { return _.reduce(glyph.ttfContours, function (sum, ctr) { return sum + ctr.length; }, 0); })); }
javascript
function getMaxPoints(font) { return _.max(_.map(font.glyphs, function (glyph) { return _.reduce(glyph.ttfContours, function (sum, ctr) { return sum + ctr.length; }, 0); })); }
[ "function", "getMaxPoints", "(", "font", ")", "{", "return", "_", ".", "max", "(", "_", ".", "map", "(", "font", ".", "glyphs", ",", "function", "(", "glyph", ")", "{", "return", "_", ".", "reduce", "(", "glyph", ".", "ttfContours", ",", "function", ...
Find max points in glyph TTF contours.
[ "Find", "max", "points", "in", "glyph", "TTF", "contours", "." ]
096f94bff960e57f66fcf98c04d14bf22f48aa5f
https://github.com/fontello/svg2ttf/blob/096f94bff960e57f66fcf98c04d14bf22f48aa5f/lib/ttf/tables/maxp.js#L9-L13
14,899
mdasberg/ng-apimock
templates/protractor.mock.js
selectScenario
function selectScenario(data, scenario) { return _execute('PUT', '/mocks', { identifier: _getIdentifier(data), scenario: scenario || null }, 'Could not select scenario [' + scenario + ']'); }
javascript
function selectScenario(data, scenario) { return _execute('PUT', '/mocks', { identifier: _getIdentifier(data), scenario: scenario || null }, 'Could not select scenario [' + scenario + ']'); }
[ "function", "selectScenario", "(", "data", ",", "scenario", ")", "{", "return", "_execute", "(", "'PUT'", ",", "'/mocks'", ",", "{", "identifier", ":", "_getIdentifier", "(", "data", ")", ",", "scenario", ":", "scenario", "||", "null", "}", ",", "'Could no...
Selects the given scenario for the mock matching the identifier. @param {Object | String} data The data object containing all the information for an expression or the name of the mock. @param scenario The scenario that is selected to be returned when the api is called. @return {Promise} the promise.
[ "Selects", "the", "given", "scenario", "for", "the", "mock", "matching", "the", "identifier", "." ]
f547e64a6bb719d2f03e5ce18fc658f70d40bf07
https://github.com/mdasberg/ng-apimock/blob/f547e64a6bb719d2f03e5ce18fc658f70d40bf07/templates/protractor.mock.js#L83-L88