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
partition
stringclasses
1 value
lorenwest/node-monitor
dist/monitor-all.js
function(options) { var t = this, json = {id: t.get('probeId')}; // Transfer all non-monitor attrs _.each(t.toJSON(options), function(value, key) { if (!(key in t.defaults)) { json[key] = value; } }); return json; }
javascript
function(options) { var t = this, json = {id: t.get('probeId')}; // Transfer all non-monitor attrs _.each(t.toJSON(options), function(value, key) { if (!(key in t.defaults)) { json[key] = value; } }); return json; }
[ "function", "(", "options", ")", "{", "var", "t", "=", "this", ",", "json", "=", "{", "id", ":", "t", ".", "get", "(", "'probeId'", ")", "}", ";", "// Transfer all non-monitor attrs", "_", ".", "each", "(", "t", ".", "toJSON", "(", "options", ")", ...
Produce an object without monitor attributes A Monitor object contains a union of the connection attributes required for a Monitor, and the additional attributes defined by the probe it's monitoring. This method produces an object containing only the probe portion of those attributes. The id attribute of the returne...
[ "Produce", "an", "object", "without", "monitor", "attributes" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L7102-L7113
train
lorenwest/node-monitor
dist/monitor-all.js
function(name, params, callback) { var t = this, controlFn = t[name + '_control'], startTime = Date.now(), errMsg, logId = 'onControl.' + t.probeClass + '.' + name; params = params || {}; callback = callback || function(){}; log.info(logId, t.get('id'), p...
javascript
function(name, params, callback) { var t = this, controlFn = t[name + '_control'], startTime = Date.now(), errMsg, logId = 'onControl.' + t.probeClass + '.' + name; params = params || {}; callback = callback || function(){}; log.info(logId, t.get('id'), p...
[ "function", "(", "name", ",", "params", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "controlFn", "=", "t", "[", "name", "+", "'_control'", "]", ",", "startTime", "=", "Date", ".", "now", "(", ")", ",", "errMsg", ",", "logId", "=", "'...
Dispatch a control message to the appropriate control function. This is called when the <a href="Monitor.html#method_control">```control()```</a> method of a monitor is called. The name determines the method name called on the probe. The probe must implement a method with the name ```{name}_control()```, and that met...
[ "Dispatch", "a", "control", "message", "to", "the", "appropriate", "control", "function", "." ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L8263-L8301
train
lorenwest/node-monitor
dist/monitor-all.js
function(attrs, callback) { var t = this, writableAttributes = t.get('writableAttributes') || []; // Validate the attributes are writable if (writableAttributes !== '*') { for (var attrName in attrs) { if (writableAttributes.indexOf(attrName) < 0) { return call...
javascript
function(attrs, callback) { var t = this, writableAttributes = t.get('writableAttributes') || []; // Validate the attributes are writable if (writableAttributes !== '*') { for (var attrName in attrs) { if (writableAttributes.indexOf(attrName) < 0) { return call...
[ "function", "(", "attrs", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "writableAttributes", "=", "t", ".", "get", "(", "'writableAttributes'", ")", "||", "[", "]", ";", "// Validate the attributes are writable", "if", "(", "writableAttributes", "!...
Remotely set a probe attribute. This allows setting probe attributes that are listed in writableAttributes. It can be overwritten in derived Probe classes for greater control. @method set_control @param attrs {Object} Name/Value attributes to set. All must be writable. @param callback {Function(error)} Called when t...
[ "Remotely", "set", "a", "probe", "attribute", "." ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L8313-L8333
train
lorenwest/node-monitor
dist/monitor-all.js
function(options, callback) { if (typeof options === 'function') { callback = options; options = null; } options = options || {}; callback = callback || function(){}; var t = this, server = t.get('server'), error, startTime = Date.now(), port = options.p...
javascript
function(options, callback) { if (typeof options === 'function') { callback = options; options = null; } options = options || {}; callback = callback || function(){}; var t = this, server = t.get('server'), error, startTime = Date.now(), port = options.p...
[ "function", "(", "options", ",", "callback", ")", "{", "if", "(", "typeof", "options", "===", "'function'", ")", "{", "callback", "=", "options", ";", "options", "=", "null", ";", "}", "options", "=", "options", "||", "{", "}", ";", "callback", "=", ...
Start accepting monitor connections This method starts listening for incoming monitor connections on the server. If the server was specified during object creation, this binds the socket.io service to the server. If the server was not specified during object creation, this will create a server on the first available...
[ "Start", "accepting", "monitor", "connections" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9019-L9083
train
lorenwest/node-monitor
dist/monitor-all.js
function(callback) { var t = this, server = t.get('server'), router = Monitor.getRouter(); callback = callback || function(){}; // Call the callback, but don't stop more than once. if (!t.isListening) { return callback(); } // Release resources t.connections.each(rout...
javascript
function(callback) { var t = this, server = t.get('server'), router = Monitor.getRouter(); callback = callback || function(){}; // Call the callback, but don't stop more than once. if (!t.isListening) { return callback(); } // Release resources t.connections.each(rout...
[ "function", "(", "callback", ")", "{", "var", "t", "=", "this", ",", "server", "=", "t", ".", "get", "(", "'server'", ")", ",", "router", "=", "Monitor", ".", "getRouter", "(", ")", ";", "callback", "=", "callback", "||", "function", "(", ")", "{",...
Stop processing inbound monitor traffic This method stops accepting new inbound monitor connections, and closes all existing monitor connections associated with the server. @method stop @param callback {Function(error)} - Called when the server has stopped The server has stopped This event is fired after the serve...
[ "Stop", "processing", "inbound", "monitor", "traffic" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9153-L9173
train
lorenwest/node-monitor
dist/monitor-all.js
function(firewall) { var t = Monitor.getRouter(); // This is a static method t.firewall = firewall; log.info('setFirewall', firewall); }
javascript
function(firewall) { var t = Monitor.getRouter(); // This is a static method t.firewall = firewall; log.info('setFirewall', firewall); }
[ "function", "(", "firewall", ")", "{", "var", "t", "=", "Monitor", ".", "getRouter", "(", ")", ";", "// This is a static method", "t", ".", "firewall", "=", "firewall", ";", "log", ".", "info", "(", "'setFirewall'", ",", "firewall", ")", ";", "}" ]
Firewall new connections from inbound probe requests When two monitor processes connect, they become peers. By default each process can request probe connections with the other. If you want to connect with a remote probe, but don't want those servers to connect with probes in this process, call this method to firewa...
[ "Firewall", "new", "connections", "from", "inbound", "probe", "requests" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9272-L9276
train
lorenwest/node-monitor
dist/monitor-all.js
function(options) { var t = this; options.gateway = false; // New connection can't be an inbound gateway options.firewall = true; // Gateways are for outbound requests only return t.defaultGateway = t.addConnection(options); }
javascript
function(options) { var t = this; options.gateway = false; // New connection can't be an inbound gateway options.firewall = true; // Gateways are for outbound requests only return t.defaultGateway = t.addConnection(options); }
[ "function", "(", "options", ")", "{", "var", "t", "=", "this", ";", "options", ".", "gateway", "=", "false", ";", "// New connection can't be an inbound gateway", "options", ".", "firewall", "=", "true", ";", "// Gateways are for outbound requests only", "return", "...
Set the default gateway server The gateway server is used if a monitor cannot connect directly with the server hosting the probe. When a monitor is requested to connect with a probe on a specific server, a direct connection is attempted. If that direct connection fails, usually due to a firewall or browser restricti...
[ "Set", "the", "default", "gateway", "server" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9303-L9308
train
lorenwest/node-monitor
dist/monitor-all.js
function() { var localStorage = root.localStorage; if (!hostName) { if (localStorage) {hostName = localStorage.hostName;} hostName = hostName || Monitor.generateUniqueId(); if (localStorage) {localStorage.hostName = hostName;} } return hostName; }
javascript
function() { var localStorage = root.localStorage; if (!hostName) { if (localStorage) {hostName = localStorage.hostName;} hostName = hostName || Monitor.generateUniqueId(); if (localStorage) {localStorage.hostName = hostName;} } return hostName; }
[ "function", "(", ")", "{", "var", "localStorage", "=", "root", ".", "localStorage", ";", "if", "(", "!", "hostName", ")", "{", "if", "(", "localStorage", ")", "{", "hostName", "=", "localStorage", ".", "hostName", ";", "}", "hostName", "=", "hostName", ...
Return a stable host name. @method getHostName @protected @return hostName {String} - The platform's host name, or an otherwise stable ID
[ "Return", "a", "stable", "host", "name", "." ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9317-L9325
train
lorenwest/node-monitor
dist/monitor-all.js
function(options) { var t = this, startTime = Date.now(); // Default the firewall value if (_.isUndefined(options.firewall)) { options = _.extend({},options, {firewall: t.firewall}); } // Generate a unique ID for the connection options.id = Monitor.generateUniqueC...
javascript
function(options) { var t = this, startTime = Date.now(); // Default the firewall value if (_.isUndefined(options.firewall)) { options = _.extend({},options, {firewall: t.firewall}); } // Generate a unique ID for the connection options.id = Monitor.generateUniqueC...
[ "function", "(", "options", ")", "{", "var", "t", "=", "this", ",", "startTime", "=", "Date", ".", "now", "(", ")", ";", "// Default the firewall value", "if", "(", "_", ".", "isUndefined", "(", "options", ".", "firewall", ")", ")", "{", "options", "="...
Add a connection to a remote Monitor process @method addConnection @protected @param options {Object} - Connection parameters @param options.hostName {String} - Name of the host to connect with @param options.hostPort {Integer} - Port number to connect with @param options.url {String} - The URL used to connect (create...
[ "Add", "a", "connection", "to", "a", "remote", "Monitor", "process" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9356-L9394
train
lorenwest/node-monitor
dist/monitor-all.js
function(connection) { var t = this; log.info('removeConnection', 'Conn_' + connection.id); connection.disconnect('connection_removed'); t.connections.remove(connection); t.trigger('connection:remove', connection); }
javascript
function(connection) { var t = this; log.info('removeConnection', 'Conn_' + connection.id); connection.disconnect('connection_removed'); t.connections.remove(connection); t.trigger('connection:remove', connection); }
[ "function", "(", "connection", ")", "{", "var", "t", "=", "this", ";", "log", ".", "info", "(", "'removeConnection'", ",", "'Conn_'", "+", "connection", ".", "id", ")", ";", "connection", ".", "disconnect", "(", "'connection_removed'", ")", ";", "t", "."...
Remove a connection from the router. This is called to remove the connection and associated routes from the router. @method removeConnection @protected @param connection {Connection} - The connection to remove
[ "Remove", "a", "connection", "from", "the", "router", "." ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9405-L9411
train
lorenwest/node-monitor
dist/monitor-all.js
function(monitor, reason, callback) { callback = callback || function(){}; var t = this, probe = monitor.probe, probeId = monitor.get('probeId'); // The monitor must be connected if (!probe) {return callback('Monitor must be connected');} // Called upon disconnect (internal or external) ...
javascript
function(monitor, reason, callback) { callback = callback || function(){}; var t = this, probe = monitor.probe, probeId = monitor.get('probeId'); // The monitor must be connected if (!probe) {return callback('Monitor must be connected');} // Called upon disconnect (internal or external) ...
[ "function", "(", "monitor", ",", "reason", ",", "callback", ")", "{", "callback", "=", "callback", "||", "function", "(", ")", "{", "}", ";", "var", "t", "=", "this", ",", "probe", "=", "monitor", ".", "probe", ",", "probeId", "=", "monitor", ".", ...
Disconnect a monitor This accepts an instance of a connected monitor, and disconnects it from the remote probe. The probe implementation will be released if this is the only monitor object watching it. @method disconnectMonitor @protected @param monitor {Monitor} - The connected monitor @param reason {String} - Reas...
[ "Disconnect", "a", "monitor" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9504-L9528
train
lorenwest/node-monitor
dist/monitor-all.js
function(probeJSON) { var probeKey = probeJSON.probeClass, initParams = probeJSON.initParams; // Allow probes to be externally identified by name if (probeJSON.probeName) { return probeJSON.probeName; } if (initParams) { _.keys(initParams).sort().forEach(functio...
javascript
function(probeJSON) { var probeKey = probeJSON.probeClass, initParams = probeJSON.initParams; // Allow probes to be externally identified by name if (probeJSON.probeName) { return probeJSON.probeName; } if (initParams) { _.keys(initParams).sort().forEach(functio...
[ "function", "(", "probeJSON", ")", "{", "var", "probeKey", "=", "probeJSON", ".", "probeClass", ",", "initParams", "=", "probeJSON", ".", "initParams", ";", "// Allow probes to be externally identified by name", "if", "(", "probeJSON", ".", "probeName", ")", "{", ...
Build a probe key from the probe data @method buildProbeKey @protected @param probeJSON {Object} - An object containing: @param probeJSON.probeName {String} - The client-defined probe name -or- @param probeJSON.probeClass {String} - The probe class name (required) @param probeJSON.initParams {Object} - Probe initializ...
[ "Build", "a", "probe", "key", "from", "the", "probe", "data" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9542-L9557
train
lorenwest/node-monitor
dist/monitor-all.js
function(hostName, appName, appInstance) { var t = this, thisInstance = 0; return t.connections.find(function(conn) { // Host or app matches if not specified or if specified and equal var matchesHost = !hostName || conn.isThisHost(hostName); var matchesApp = !appName || appName === ...
javascript
function(hostName, appName, appInstance) { var t = this, thisInstance = 0; return t.connections.find(function(conn) { // Host or app matches if not specified or if specified and equal var matchesHost = !hostName || conn.isThisHost(hostName); var matchesApp = !appName || appName === ...
[ "function", "(", "hostName", ",", "appName", ",", "appInstance", ")", "{", "var", "t", "=", "this", ",", "thisInstance", "=", "0", ";", "return", "t", ".", "connections", ".", "find", "(", "function", "(", "conn", ")", "{", "// Host or app matches if not s...
Find an existing connection to use This method looks into the existing known connections to find one that matches the specified parameters. Firewalled connections are not returned. @method findConnection @protected @param hostName {String} - Host name to find a connection for (null = any host) @param appName {String...
[ "Find", "an", "existing", "connection", "to", "use" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9741-L9754
train
lorenwest/node-monitor
dist/monitor-all.js
function(hostName, appName) { var t = this; return t.connections.filter(function(conn) { // Host or app matches if not specified or if specified and equal var matchesHost = !hostName || conn.isThisHost(hostName); var matchesApp = !appName || appName === conn.get('remoteAppName'); ...
javascript
function(hostName, appName) { var t = this; return t.connections.filter(function(conn) { // Host or app matches if not specified or if specified and equal var matchesHost = !hostName || conn.isThisHost(hostName); var matchesApp = !appName || appName === conn.get('remoteAppName'); ...
[ "function", "(", "hostName", ",", "appName", ")", "{", "var", "t", "=", "this", ";", "return", "t", ".", "connections", ".", "filter", "(", "function", "(", "conn", ")", "{", "// Host or app matches if not specified or if specified and equal", "var", "matchesHost"...
Find all connections matching the selection criteria This method looks into the existing known connections to find all that match the specified parameters. Firewalled connections are not returned. @method findConnections @protected @param hostName {String} - Host name to search for (null = any host) @param appName {...
[ "Find", "all", "connections", "matching", "the", "selection", "criteria" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9770-L9782
train
lorenwest/node-monitor
dist/monitor-all.js
function(hostName, callback) { var t = this, errStr = '', connectedPorts = [], portStart = Config.Monitor.serviceBasePort, portEnd = Config.Monitor.serviceBasePort + Config.Monitor.portsToScan - 1; // Create an array to hold callbacks for this host if (!t.addHo...
javascript
function(hostName, callback) { var t = this, errStr = '', connectedPorts = [], portStart = Config.Monitor.serviceBasePort, portEnd = Config.Monitor.serviceBasePort + Config.Monitor.portsToScan - 1; // Create an array to hold callbacks for this host if (!t.addHo...
[ "function", "(", "hostName", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "errStr", "=", "''", ",", "connectedPorts", "=", "[", "]", ",", "portStart", "=", "Config", ".", "Monitor", ".", "serviceBasePort", ",", "portEnd", "=", "Config", "."...
Add connections for the specified host This performs a scan of monitor ports on the server, and adds connections for newly discovered servers. It can take a while to complete, and if called for the same host before completion, it will save the callback and call all callbacks when the original task is complete. @meth...
[ "Add", "connections", "for", "the", "specified", "host" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9799-L9853
train
lorenwest/node-monitor
dist/monitor-all.js
function(error) { t.addHostCallbacks[hostName].forEach(function(cb) { cb(error); }); delete t.addHostCallbacks[hostName]; }
javascript
function(error) { t.addHostCallbacks[hostName].forEach(function(cb) { cb(error); }); delete t.addHostCallbacks[hostName]; }
[ "function", "(", "error", ")", "{", "t", ".", "addHostCallbacks", "[", "hostName", "]", ".", "forEach", "(", "function", "(", "cb", ")", "{", "cb", "(", "error", ")", ";", "}", ")", ";", "delete", "t", ".", "addHostCallbacks", "[", "hostName", "]", ...
Called when done
[ "Called", "when", "done" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9817-L9822
train
lorenwest/node-monitor
dist/monitor-all.js
function(probeId, callback) { var t = this, probeImpl = t.runningProbesById[probeId]; if (!probeImpl) {return callback('Probe not running');} if (--probeImpl.refCount === 0) { // Release probe resources & internal references if still no references after a while setTimeout(function() {...
javascript
function(probeId, callback) { var t = this, probeImpl = t.runningProbesById[probeId]; if (!probeImpl) {return callback('Probe not running');} if (--probeImpl.refCount === 0) { // Release probe resources & internal references if still no references after a while setTimeout(function() {...
[ "function", "(", "probeId", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "probeImpl", "=", "t", ".", "runningProbesById", "[", "probeId", "]", ";", "if", "(", "!", "probeImpl", ")", "{", "return", "callback", "(", "'Probe not running'", ")", ...
Disconnect with an internal probe implementation. @method disconnectInternal @protected @param probeId {String} - The probe implementation ID to disconnect @param callback {Function(error, probeImpl)} - Called when disconnected
[ "Disconnect", "with", "an", "internal", "probe", "implementation", "." ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9961-L9978
train
lorenwest/node-monitor
dist/monitor-all.js
function(monitorJSON, connection, callback) { // Build a key for this probe from the probeClass and initParams var t = this, errStr = '', probeKey = t.buildProbeKey(monitorJSON); // Get the probe proxy var probeId = connection.remoteProbeIdsByKey[probeKey]; var probeP...
javascript
function(monitorJSON, connection, callback) { // Build a key for this probe from the probeClass and initParams var t = this, errStr = '', probeKey = t.buildProbeKey(monitorJSON); // Get the probe proxy var probeId = connection.remoteProbeIdsByKey[probeKey]; var probeP...
[ "function", "(", "monitorJSON", ",", "connection", ",", "callback", ")", "{", "// Build a key for this probe from the probeClass and initParams", "var", "t", "=", "this", ",", "errStr", "=", "''", ",", "probeKey", "=", "t", ".", "buildProbeKey", "(", "monitorJSON", ...
Connect to an external probe implementation. This connects with a probe running in another process. It will coordinate the remote instantiation of the probe if it's not running. @method connectExternal @protected @param monitorJSON {Object} - An object containing: @param monitorJSON.probeClass {String} - The probe c...
[ "Connect", "to", "an", "external", "probe", "implementation", "." ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L9994-L10041
train
lorenwest/node-monitor
dist/monitor-all.js
function(connection, probeId, callback) { var t = this, proxy = connection.remoteProbesById[probeId]; if (!proxy) {return callback('Probe not running');} if (--proxy.refCount === 0) { // Release probe resources proxy.release(); proxy.connection = null; delete connection...
javascript
function(connection, probeId, callback) { var t = this, proxy = connection.remoteProbesById[probeId]; if (!proxy) {return callback('Probe not running');} if (--proxy.refCount === 0) { // Release probe resources proxy.release(); proxy.connection = null; delete connection...
[ "function", "(", "connection", ",", "probeId", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "proxy", "=", "connection", ".", "remoteProbesById", "[", "probeId", "]", ";", "if", "(", "!", "proxy", ")", "{", "return", "callback", "(", "'Probe...
Disconnect with an external probe implementation. @method disconnectExternal @protected @param connection {Connection} - The connection to use @param probeId {String} - Probe ID @param callback {Function(error)} - Called when disconnected
[ "Disconnect", "with", "an", "external", "probe", "implementation", "." ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10052-L10067
train
lorenwest/node-monitor
dist/monitor-all.js
function(error) { // Don't connect the instance monitor if errors if (error) { return callback(error); } // Called to disconnect the listeners var disconnectListeners = function() { logger.info('disconnectLiveSync', t.className, model.toJSON()); model.off('change'...
javascript
function(error) { // Don't connect the instance monitor if errors if (error) { return callback(error); } // Called to disconnect the listeners var disconnectListeners = function() { logger.info('disconnectLiveSync', t.className, model.toJSON()); model.off('change'...
[ "function", "(", "error", ")", "{", "// Don't connect the instance monitor if errors", "if", "(", "error", ")", "{", "return", "callback", "(", "error", ")", ";", "}", "// Called to disconnect the listeners", "var", "disconnectListeners", "=", "function", "(", ")", ...
Called when done connecting
[ "Called", "when", "done", "connecting" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10340-L10416
train
lorenwest/node-monitor
dist/monitor-all.js
function() { logger.info('disconnectLiveSync', t.className, model.toJSON()); model.off('change', modelListener); model.syncMonitor.off('change', monitorListener); model.syncMonitor.disconnect(); model.syncMonitor = null; }
javascript
function() { logger.info('disconnectLiveSync', t.className, model.toJSON()); model.off('change', modelListener); model.syncMonitor.off('change', monitorListener); model.syncMonitor.disconnect(); model.syncMonitor = null; }
[ "function", "(", ")", "{", "logger", ".", "info", "(", "'disconnectLiveSync'", ",", "t", ".", "className", ",", "model", ".", "toJSON", "(", ")", ")", ";", "model", ".", "off", "(", "'change'", ",", "modelListener", ")", ";", "model", ".", "syncMonitor...
Called to disconnect the listeners
[ "Called", "to", "disconnect", "the", "listeners" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10348-L10354
train
lorenwest/node-monitor
dist/monitor-all.js
function(changedModel, options) { options = options || {}; // Don't persist unless the model is different if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(model.syncMonitor.get('model'))))) { logger.info('modelListener.noChanges', t.className, model.toJSON())...
javascript
function(changedModel, options) { options = options || {}; // Don't persist unless the model is different if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(model.syncMonitor.get('model'))))) { logger.info('modelListener.noChanges', t.className, model.toJSON())...
[ "function", "(", "changedModel", ",", "options", ")", "{", "options", "=", "options", "||", "{", "}", ";", "// Don't persist unless the model is different", "if", "(", "_", ".", "isEqual", "(", "JSON", ".", "parse", "(", "JSON", ".", "stringify", "(", "model...
Client-side listener - for persisting changes to the server
[ "Client", "-", "side", "listener", "-", "for", "persisting", "changes", "to", "the", "server" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10357-L10377
train
lorenwest/node-monitor
dist/monitor-all.js
function(params, callback) { var t = this, connectError = false, monitors = t.get('monitors'); if (t.get('started')) { var err = {code:'RUNNING', msg:'Cannot start - the recipe is already running.'}; logger.warn(err); return callback(err); } // Calle...
javascript
function(params, callback) { var t = this, connectError = false, monitors = t.get('monitors'); if (t.get('started')) { var err = {code:'RUNNING', msg:'Cannot start - the recipe is already running.'}; logger.warn(err); return callback(err); } // Calle...
[ "function", "(", "params", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "connectError", "=", "false", ",", "monitors", "=", "t", ".", "get", "(", "'monitors'", ")", ";", "if", "(", "t", ".", "get", "(", "'started'", ")", ")", "{", "va...
Start the recipe This connects to each monitor and sets up the recipe triggers @method start_control
[ "Start", "the", "recipe" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10654-L10690
train
lorenwest/node-monitor
dist/monitor-all.js
function(error) { if (connectError) {return;} if (error) { var err = {code:'CONNECT_ERROR', err: error}; connectError = true; logger.error('start', err); return callback(err); } for (var name1 in t.monitors) { if (!t.monitors[name1].isCon...
javascript
function(error) { if (connectError) {return;} if (error) { var err = {code:'CONNECT_ERROR', err: error}; connectError = true; logger.error('start', err); return callback(err); } for (var name1 in t.monitors) { if (!t.monitors[name1].isCon...
[ "function", "(", "error", ")", "{", "if", "(", "connectError", ")", "{", "return", ";", "}", "if", "(", "error", ")", "{", "var", "err", "=", "{", "code", ":", "'CONNECT_ERROR'", ",", "err", ":", "error", "}", ";", "connectError", "=", "true", ";",...
Called when a monitor has connected
[ "Called", "when", "a", "monitor", "has", "connected" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10666-L10682
train
lorenwest/node-monitor
dist/monitor-all.js
function(params, callback) { var t = this, disconnectError = false; if (!t.get('started')) { var err = {code:'NOT_RUNNING', msg:'The recipe is already stopped.'}; logger.warn('precondition', err); return callback(err); } // Called when a monitor has disconnect...
javascript
function(params, callback) { var t = this, disconnectError = false; if (!t.get('started')) { var err = {code:'NOT_RUNNING', msg:'The recipe is already stopped.'}; logger.warn('precondition', err); return callback(err); } // Called when a monitor has disconnect...
[ "function", "(", "params", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "disconnectError", "=", "false", ";", "if", "(", "!", "t", ".", "get", "(", "'started'", ")", ")", "{", "var", "err", "=", "{", "code", ":", "'NOT_RUNNING'", ",", ...
Stop the recipe This disconnects each monitor @method stop_control
[ "Stop", "the", "recipe" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10699-L10734
train
lorenwest/node-monitor
dist/monitor-all.js
function(error) { if (disconnectError) {return;} if (error) { var err = {code:'DISONNECT_ERROR', err: error}; disconnectError = true; logger.error('onDisconnect', err); return callback(err); } for (var name1 in t.monitors) { if (t.monitor...
javascript
function(error) { if (disconnectError) {return;} if (error) { var err = {code:'DISONNECT_ERROR', err: error}; disconnectError = true; logger.error('onDisconnect', err); return callback(err); } for (var name1 in t.monitors) { if (t.monitor...
[ "function", "(", "error", ")", "{", "if", "(", "disconnectError", ")", "{", "return", ";", "}", "if", "(", "error", ")", "{", "var", "err", "=", "{", "code", ":", "'DISONNECT_ERROR'", ",", "err", ":", "error", "}", ";", "disconnectError", "=", "true"...
Called when a monitor has disconnected
[ "Called", "when", "a", "monitor", "has", "disconnected" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10710-L10726
train
lorenwest/node-monitor
dist/monitor-all.js
function(connect) { var t = this, triggeredBy = t.get('triggeredBy'), onTrigger = t.onTrigger.bind(t); // Default to listen on changes to all monitors if (!triggeredBy) { for (var monitorName in t.monitors) { t.monitors[monitorName][connect ? 'on' : 'off']('chang...
javascript
function(connect) { var t = this, triggeredBy = t.get('triggeredBy'), onTrigger = t.onTrigger.bind(t); // Default to listen on changes to all monitors if (!triggeredBy) { for (var monitorName in t.monitors) { t.monitors[monitorName][connect ? 'on' : 'off']('chang...
[ "function", "(", "connect", ")", "{", "var", "t", "=", "this", ",", "triggeredBy", "=", "t", ".", "get", "(", "'triggeredBy'", ")", ",", "onTrigger", "=", "t", ".", "onTrigger", ".", "bind", "(", "t", ")", ";", "// Default to listen on changes to all monit...
Connect the change listeners @private @method connectListeners
[ "Connect", "the", "change", "listeners" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10742-L10790
train
lorenwest/node-monitor
dist/monitor-all.js
function(params, callback) { var t = this, error = null; if (!t.get('started')) { error = {code:'NOT_RUNNING', msg:'Cannot run - recipe not started.'}; logger.warn(error); return callback(error); } // Name the probe t.name = t.get('probeName') || t.get('i...
javascript
function(params, callback) { var t = this, error = null; if (!t.get('started')) { error = {code:'NOT_RUNNING', msg:'Cannot run - recipe not started.'}; logger.warn(error); return callback(error); } // Name the probe t.name = t.get('probeName') || t.get('i...
[ "function", "(", "params", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "error", "=", "null", ";", "if", "(", "!", "t", ".", "get", "(", "'started'", ")", ")", "{", "error", "=", "{", "code", ":", "'NOT_RUNNING'", ",", "msg", ":", "...
Run the recipe script This manually runs a started recipe. The callback is called immediately after executing the script. @method run_control
[ "Run", "the", "recipe", "script" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10815-L10846
train
lorenwest/node-monitor
dist/monitor-all.js
function(context) { var varName, localVars = []; for (varName in context) { localVars.push('var ' + varName + ' = context.' + varName + ';'); } return localVars.join('\n'); }
javascript
function(context) { var varName, localVars = []; for (varName in context) { localVars.push('var ' + varName + ' = context.' + varName + ';'); } return localVars.join('\n'); }
[ "function", "(", "context", ")", "{", "var", "varName", ",", "localVars", "=", "[", "]", ";", "for", "(", "varName", "in", "context", ")", "{", "localVars", ".", "push", "(", "'var '", "+", "varName", "+", "' = context.'", "+", "varName", "+", "';'", ...
Generate a script that brings context members into local scope @private @method bringLocal
[ "Generate", "a", "script", "that", "brings", "context", "members", "into", "local", "scope" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L10883-L10890
train
lorenwest/node-monitor
dist/monitor-all.js
function(item) { var t = this, now = Date.now(), msSinceLastSend = now - t.lastSendTime; // Queue the item t.queue.push(item); // Send the bundle? if (msSinceLastSend > t.interval) { // It's been a while since the last send. Send it now. t._send(); ...
javascript
function(item) { var t = this, now = Date.now(), msSinceLastSend = now - t.lastSendTime; // Queue the item t.queue.push(item); // Send the bundle? if (msSinceLastSend > t.interval) { // It's been a while since the last send. Send it now. t._send(); ...
[ "function", "(", "item", ")", "{", "var", "t", "=", "this", ",", "now", "=", "Date", ".", "now", "(", ")", ",", "msSinceLastSend", "=", "now", "-", "t", ".", "lastSendTime", ";", "// Queue the item", "t", ".", "queue", ".", "push", "(", "item", ")"...
Queue an item in the stream This method places the item into the stream and outputs it to the monitor, or queues it up for the next bundle. @method queueItem @param item {Any} Item to place into the queue
[ "Queue", "an", "item", "in", "the", "stream" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L11062-L11083
train
lorenwest/node-monitor
dist/monitor-all.js
function() { var t = this, now = Date.now(); // This kicks off the send t.lastSendTime = now; t.set({ bundle: t.queue, sequence: t.get('sequence') + 1 }); // Reset t.queue = []; if (t.timer) { clearTimeout(t.timer); t.timer = nu...
javascript
function() { var t = this, now = Date.now(); // This kicks off the send t.lastSendTime = now; t.set({ bundle: t.queue, sequence: t.get('sequence') + 1 }); // Reset t.queue = []; if (t.timer) { clearTimeout(t.timer); t.timer = nu...
[ "function", "(", ")", "{", "var", "t", "=", "this", ",", "now", "=", "Date", ".", "now", "(", ")", ";", "// This kicks off the send", "t", ".", "lastSendTime", "=", "now", ";", "t", ".", "set", "(", "{", "bundle", ":", "t", ".", "queue", ",", "se...
Send the bundle to the montitor @private @method _send
[ "Send", "the", "bundle", "to", "the", "montitor" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/dist/monitor-all.js#L11091-L11108
train
lorenwest/node-monitor
lib/probes/FileSyncProbe.js
function(error, content) { var isInitializing = (callback !== null), initCallback = callback; callback = null; if (error && error.code === 'ENOENT') { // File doesn't exist. Set the model to null. t.set({model: {}}, {silent: isInitializing}); ...
javascript
function(error, content) { var isInitializing = (callback !== null), initCallback = callback; callback = null; if (error && error.code === 'ENOENT') { // File doesn't exist. Set the model to null. t.set({model: {}}, {silent: isInitializing}); ...
[ "function", "(", "error", ",", "content", ")", "{", "var", "isInitializing", "=", "(", "callback", "!==", "null", ")", ",", "initCallback", "=", "callback", ";", "callback", "=", "null", ";", "if", "(", "error", "&&", "error", ".", "code", "===", "'ENO...
Build the function to watch the file
[ "Build", "the", "function", "to", "watch", "the", "file" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/lib/probes/FileSyncProbe.js#L73-L122
train
lorenwest/node-monitor
lib/probes/FileSyncProbe.js
function(args, callback) { // Make sure the ID exists var t = this, model = args.model; if (!model || !model.id) { return callback({msg:'SyncProbe create - Data model with ID not present'}); } // Make sure the file doesn't already exist t.getFullPath(model.id, function(error...
javascript
function(args, callback) { // Make sure the ID exists var t = this, model = args.model; if (!model || !model.id) { return callback({msg:'SyncProbe create - Data model with ID not present'}); } // Make sure the file doesn't already exist t.getFullPath(model.id, function(error...
[ "function", "(", "args", ",", "callback", ")", "{", "// Make sure the ID exists", "var", "t", "=", "this", ",", "model", "=", "args", ".", "model", ";", "if", "(", "!", "model", "||", "!", "model", ".", "id", ")", "{", "return", "callback", "(", "{",...
Documentation for these methods in SyncProbe
[ "Documentation", "for", "these", "methods", "in", "SyncProbe" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/lib/probes/FileSyncProbe.js#L135-L155
train
lorenwest/node-monitor
lib/probes/FileSyncProbe.js
function(modelId, callback) { var t = this, dirPath = t.dirPath; // Don't allow relative paths var fullPath = Path.join(t.dirPath, modelId); if (fullPath.indexOf(dirPath) !== 0) { return callback({msg: 'Model ID ' + modelId + ' cannot represent a relative path'}); } ...
javascript
function(modelId, callback) { var t = this, dirPath = t.dirPath; // Don't allow relative paths var fullPath = Path.join(t.dirPath, modelId); if (fullPath.indexOf(dirPath) !== 0) { return callback({msg: 'Model ID ' + modelId + ' cannot represent a relative path'}); } ...
[ "function", "(", "modelId", ",", "callback", ")", "{", "var", "t", "=", "this", ",", "dirPath", "=", "t", ".", "dirPath", ";", "// Don't allow relative paths", "var", "fullPath", "=", "Path", ".", "join", "(", "t", ".", "dirPath", ",", "modelId", ")", ...
Get the full path to the file This builds the full pathname to the file, and performs an fs.sync() on that pathname, providing the pathname and sync object in the callback. @method getFullPath @param modelId {String} ID of the data model to sync @param callback {Function(error, return)} @param callback.error {Object}...
[ "Get", "the", "full", "path", "to", "the", "file" ]
7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8
https://github.com/lorenwest/node-monitor/blob/7afd5d22c1d44b93c7cb2250ea9e05ef7b8451f8/lib/probes/FileSyncProbe.js#L275-L311
train
mscdex/node-ncurses
lib/widgets.js
extend
function extend() { // copy reference to target object var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; // Handle a deep copy situation if (typeof target === "boolean") { deep = target; target = arguments[1] || {}; // skip the boolean and the...
javascript
function extend() { // copy reference to target object var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy; // Handle a deep copy situation if (typeof target === "boolean") { deep = target; target = arguments[1] || {}; // skip the boolean and the...
[ "function", "extend", "(", ")", "{", "// copy reference to target object", "var", "target", "=", "arguments", "[", "0", "]", "||", "{", "}", ",", "i", "=", "1", ",", "length", "=", "arguments", ".", "length", ",", "deep", "=", "false", ",", "options", ...
Adopted from jquery's extend method. Under the terms of MIT License. http://code.jquery.com/jquery-1.4.2.js Modified by Brian White to use Array.isArray instead of the custom isArray method
[ "Adopted", "from", "jquery", "s", "extend", "method", ".", "Under", "the", "terms", "of", "MIT", "License", "." ]
f013b5584ac62eb002e63632c61d98daafd2c4c5
https://github.com/mscdex/node-ncurses/blob/f013b5584ac62eb002e63632c61d98daafd2c4c5/lib/widgets.js#L959-L1013
train
retextjs/retext-smartypants
index.js
transformFactory
function transformFactory(methods) { var length = methods.length return transformer // Transformer. function transformer(cst) { visit(cst, visitor) } function visitor(node, position, parent) { var index = -1 if (node.type === punctuation || node.type === symbol) { while (++index < leng...
javascript
function transformFactory(methods) { var length = methods.length return transformer // Transformer. function transformer(cst) { visit(cst, visitor) } function visitor(node, position, parent) { var index = -1 if (node.type === punctuation || node.type === symbol) { while (++index < leng...
[ "function", "transformFactory", "(", "methods", ")", "{", "var", "length", "=", "methods", ".", "length", "return", "transformer", "// Transformer.", "function", "transformer", "(", "cst", ")", "{", "visit", "(", "cst", ",", "visitor", ")", "}", "function", ...
Create a transformer for the bound methods.
[ "Create", "a", "transformer", "for", "the", "bound", "methods", "." ]
4d4ce9059db4f4cafd07a31fedc218c11738435f
https://github.com/retextjs/retext-smartypants/blob/4d4ce9059db4f4cafd07a31fedc218c11738435f/index.js#L175-L194
train
retextjs/retext-smartypants
index.js
oldschool
function oldschool(node) { if (node.value === threeDashes) { node.value = emDash } else if (node.value === twoDashes) { node.value = enDash } }
javascript
function oldschool(node) { if (node.value === threeDashes) { node.value = emDash } else if (node.value === twoDashes) { node.value = enDash } }
[ "function", "oldschool", "(", "node", ")", "{", "if", "(", "node", ".", "value", "===", "threeDashes", ")", "{", "node", ".", "value", "=", "emDash", "}", "else", "if", "(", "node", ".", "value", "===", "twoDashes", ")", "{", "node", ".", "value", ...
Transform three dahes into an em-dash, and two into an en-dash.
[ "Transform", "three", "dahes", "into", "an", "em", "-", "dash", "and", "two", "into", "an", "en", "-", "dash", "." ]
4d4ce9059db4f4cafd07a31fedc218c11738435f
https://github.com/retextjs/retext-smartypants/blob/4d4ce9059db4f4cafd07a31fedc218c11738435f/index.js#L197-L203
train
retextjs/retext-smartypants
index.js
inverted
function inverted(node) { if (node.value === threeDashes) { node.value = enDash } else if (node.value === twoDashes) { node.value = emDash } }
javascript
function inverted(node) { if (node.value === threeDashes) { node.value = enDash } else if (node.value === twoDashes) { node.value = emDash } }
[ "function", "inverted", "(", "node", ")", "{", "if", "(", "node", ".", "value", "===", "threeDashes", ")", "{", "node", ".", "value", "=", "enDash", "}", "else", "if", "(", "node", ".", "value", "===", "twoDashes", ")", "{", "node", ".", "value", "...
Transform three dahes into an en-dash, and two into an em-dash.
[ "Transform", "three", "dahes", "into", "an", "en", "-", "dash", "and", "two", "into", "an", "em", "-", "dash", "." ]
4d4ce9059db4f4cafd07a31fedc218c11738435f
https://github.com/retextjs/retext-smartypants/blob/4d4ce9059db4f4cafd07a31fedc218c11738435f/index.js#L213-L219
train
retextjs/retext-smartypants
index.js
backticks
function backticks(node) { if (node.value === twoBackticks) { node.value = openingDoubleQuote } else if (node.value === twoSingleQuotes) { node.value = closingDoubleQuote } }
javascript
function backticks(node) { if (node.value === twoBackticks) { node.value = openingDoubleQuote } else if (node.value === twoSingleQuotes) { node.value = closingDoubleQuote } }
[ "function", "backticks", "(", "node", ")", "{", "if", "(", "node", ".", "value", "===", "twoBackticks", ")", "{", "node", ".", "value", "=", "openingDoubleQuote", "}", "else", "if", "(", "node", ".", "value", "===", "twoSingleQuotes", ")", "{", "node", ...
Transform double backticks and single quotes into smart quotes.
[ "Transform", "double", "backticks", "and", "single", "quotes", "into", "smart", "quotes", "." ]
4d4ce9059db4f4cafd07a31fedc218c11738435f
https://github.com/retextjs/retext-smartypants/blob/4d4ce9059db4f4cafd07a31fedc218c11738435f/index.js#L222-L228
train
retextjs/retext-smartypants
index.js
all
function all(node) { backticks(node) if (node.value === backtick) { node.value = openingSingleQuote } else if (node.value === singleQuote) { node.value = closingSingleQuote } }
javascript
function all(node) { backticks(node) if (node.value === backtick) { node.value = openingSingleQuote } else if (node.value === singleQuote) { node.value = closingSingleQuote } }
[ "function", "all", "(", "node", ")", "{", "backticks", "(", "node", ")", "if", "(", "node", ".", "value", "===", "backtick", ")", "{", "node", ".", "value", "=", "openingSingleQuote", "}", "else", "if", "(", "node", ".", "value", "===", "singleQuote", ...
Transform single and double backticks and single quotes into smart quotes.
[ "Transform", "single", "and", "double", "backticks", "and", "single", "quotes", "into", "smart", "quotes", "." ]
4d4ce9059db4f4cafd07a31fedc218c11738435f
https://github.com/retextjs/retext-smartypants/blob/4d4ce9059db4f4cafd07a31fedc218c11738435f/index.js#L231-L239
train
retextjs/retext-smartypants
index.js
ellipses
function ellipses(node, index, parent) { var value = node.value var siblings = parent.children var position var nodes var sibling var type var count var queue // Simple node with three dots and without white-space. if (threeFullStopsExpression.test(node.value)) { node.value = ellipsis retur...
javascript
function ellipses(node, index, parent) { var value = node.value var siblings = parent.children var position var nodes var sibling var type var count var queue // Simple node with three dots and without white-space. if (threeFullStopsExpression.test(node.value)) { node.value = ellipsis retur...
[ "function", "ellipses", "(", "node", ",", "index", ",", "parent", ")", "{", "var", "value", "=", "node", ".", "value", "var", "siblings", "=", "parent", ".", "children", "var", "position", "var", "nodes", "var", "sibling", "var", "type", "var", "count", ...
Transform multiple dots into unicode ellipses.
[ "Transform", "multiple", "dots", "into", "unicode", "ellipses", "." ]
4d4ce9059db4f4cafd07a31fedc218c11738435f
https://github.com/retextjs/retext-smartypants/blob/4d4ce9059db4f4cafd07a31fedc218c11738435f/index.js#L242-L303
train
retextjs/retext-smartypants
index.js
quotes
function quotes(node, index, parent) { var siblings = parent.children var value = node.value var next var nextNext var prev var nextValue if (value !== doubleQuote && value !== singleQuote) { return } prev = siblings[index - 1] next = siblings[index + 1] nextNext = siblings[index + 2] next...
javascript
function quotes(node, index, parent) { var siblings = parent.children var value = node.value var next var nextNext var prev var nextValue if (value !== doubleQuote && value !== singleQuote) { return } prev = siblings[index - 1] next = siblings[index + 1] nextNext = siblings[index + 2] next...
[ "function", "quotes", "(", "node", ",", "index", ",", "parent", ")", "{", "var", "siblings", "=", "parent", ".", "children", "var", "value", "=", "node", ".", "value", "var", "next", "var", "nextNext", "var", "prev", "var", "nextValue", "if", "(", "val...
Transform straight single- and double quotes into smart quotes.
[ "Transform", "straight", "single", "-", "and", "double", "quotes", "into", "smart", "quotes", "." ]
4d4ce9059db4f4cafd07a31fedc218c11738435f
https://github.com/retextjs/retext-smartypants/blob/4d4ce9059db4f4cafd07a31fedc218c11738435f/index.js#L306-L371
train
ethjs/ethjs-util
src/index.js
padToEven
function padToEven(value) { var a = value; // eslint-disable-line if (typeof a !== 'string') { throw new Error(`[ethjs-util] while padding to even, value must be string, is currently ${typeof a}, while padToEven.`); } if (a.length % 2) { a = `0${a}`; } return a; }
javascript
function padToEven(value) { var a = value; // eslint-disable-line if (typeof a !== 'string') { throw new Error(`[ethjs-util] while padding to even, value must be string, is currently ${typeof a}, while padToEven.`); } if (a.length % 2) { a = `0${a}`; } return a; }
[ "function", "padToEven", "(", "value", ")", "{", "var", "a", "=", "value", ";", "// eslint-disable-line", "if", "(", "typeof", "a", "!==", "'string'", ")", "{", "throw", "new", "Error", "(", "`", "${", "typeof", "a", "}", "`", ")", ";", "}", "if", ...
Pads a `String` to have an even length @param {String} value @return {String} output
[ "Pads", "a", "String", "to", "have", "an", "even", "length" ]
e9aede668177b6d1ea62d741ba1c19402bc337b3
https://github.com/ethjs/ethjs-util/blob/e9aede668177b6d1ea62d741ba1c19402bc337b3/src/index.js#L9-L21
train
ethjs/ethjs-util
src/index.js
arrayContainsArray
function arrayContainsArray(superset, subset, some) { if (Array.isArray(superset) !== true) { throw new Error(`[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '${typeof superset}'`); } if (Array.isArray(subset) !== true) { throw new Error(`[ethjs-util] method arrayContainsAr...
javascript
function arrayContainsArray(superset, subset, some) { if (Array.isArray(superset) !== true) { throw new Error(`[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '${typeof superset}'`); } if (Array.isArray(subset) !== true) { throw new Error(`[ethjs-util] method arrayContainsAr...
[ "function", "arrayContainsArray", "(", "superset", ",", "subset", ",", "some", ")", "{", "if", "(", "Array", ".", "isArray", "(", "superset", ")", "!==", "true", ")", "{", "throw", "new", "Error", "(", "`", "${", "typeof", "superset", "}", "`", ")", ...
Returns TRUE if the first specified array contains all elements from the second one. FALSE otherwise. @param {array} superset @param {array} subset @returns {boolean}
[ "Returns", "TRUE", "if", "the", "first", "specified", "array", "contains", "all", "elements", "from", "the", "second", "one", ".", "FALSE", "otherwise", "." ]
e9aede668177b6d1ea62d741ba1c19402bc337b3
https://github.com/ethjs/ethjs-util/blob/e9aede668177b6d1ea62d741ba1c19402bc337b3/src/index.js#L67-L72
train
ethjs/ethjs-util
src/index.js
toUtf8
function toUtf8(hex) { const bufferValue = new Buffer(padToEven(stripHexPrefix(hex).replace(/^0+|0+$/g, '')), 'hex'); return bufferValue.toString('utf8'); }
javascript
function toUtf8(hex) { const bufferValue = new Buffer(padToEven(stripHexPrefix(hex).replace(/^0+|0+$/g, '')), 'hex'); return bufferValue.toString('utf8'); }
[ "function", "toUtf8", "(", "hex", ")", "{", "const", "bufferValue", "=", "new", "Buffer", "(", "padToEven", "(", "stripHexPrefix", "(", "hex", ")", ".", "replace", "(", "/", "^0+|0+$", "/", "g", ",", "''", ")", ")", ",", "'hex'", ")", ";", "return", ...
Should be called to get utf8 from it's hex representation @method toUtf8 @param {String} string in hex @returns {String} ascii string representation of hex value
[ "Should", "be", "called", "to", "get", "utf8", "from", "it", "s", "hex", "representation" ]
e9aede668177b6d1ea62d741ba1c19402bc337b3
https://github.com/ethjs/ethjs-util/blob/e9aede668177b6d1ea62d741ba1c19402bc337b3/src/index.js#L81-L85
train
ethjs/ethjs-util
src/index.js
toAscii
function toAscii(hex) { var str = ''; // eslint-disable-line var i = 0, l = hex.length; // eslint-disable-line if (hex.substring(0, 2) === '0x') { i = 2; } for (; i < l; i += 2) { const code = parseInt(hex.substr(i, 2), 16); str += String.fromCharCode(code); } return str; }
javascript
function toAscii(hex) { var str = ''; // eslint-disable-line var i = 0, l = hex.length; // eslint-disable-line if (hex.substring(0, 2) === '0x') { i = 2; } for (; i < l; i += 2) { const code = parseInt(hex.substr(i, 2), 16); str += String.fromCharCode(code); } return str; }
[ "function", "toAscii", "(", "hex", ")", "{", "var", "str", "=", "''", ";", "// eslint-disable-line", "var", "i", "=", "0", ",", "l", "=", "hex", ".", "length", ";", "// eslint-disable-line", "if", "(", "hex", ".", "substring", "(", "0", ",", "2", ")"...
Should be called to get ascii from it's hex representation @method toAscii @param {String} string in hex @returns {String} ascii string representation of hex value
[ "Should", "be", "called", "to", "get", "ascii", "from", "it", "s", "hex", "representation" ]
e9aede668177b6d1ea62d741ba1c19402bc337b3
https://github.com/ethjs/ethjs-util/blob/e9aede668177b6d1ea62d741ba1c19402bc337b3/src/index.js#L94-L108
train
nathanbuchar/node-cipher
bin/actions/cipher.js
prompForPassword
function prompForPassword(done) { inquirer.prompt([ { type: 'password', message: 'Enter the password', name: 'password', validate(input) { return input.length > 0; } } ], answers => { done(answers.password); }); }
javascript
function prompForPassword(done) { inquirer.prompt([ { type: 'password', message: 'Enter the password', name: 'password', validate(input) { return input.length > 0; } } ], answers => { done(answers.password); }); }
[ "function", "prompForPassword", "(", "done", ")", "{", "inquirer", ".", "prompt", "(", "[", "{", "type", ":", "'password'", ",", "message", ":", "'Enter the password'", ",", "name", ":", "'password'", ",", "validate", "(", "input", ")", "{", "return", "inp...
Prompts the user to supply a password via Inquirer. @param {Function} done
[ "Prompts", "the", "user", "to", "supply", "a", "password", "via", "Inquirer", "." ]
e35ae0ad48a7907a0abd94a8f31daff0a967334f
https://github.com/nathanbuchar/node-cipher/blob/e35ae0ad48a7907a0abd94a8f31daff0a967334f/bin/actions/cipher.js#L19-L32
train
nathanbuchar/node-cipher
bin/actions/cipher.js
parseOptions
function parseOptions(options) { let opts = {}; _.each(nodecipher.defaults, (defaultVal, name) => { if (!_.isUndefined(options[name])) { opts[name] = options[name]; } }); return opts; }
javascript
function parseOptions(options) { let opts = {}; _.each(nodecipher.defaults, (defaultVal, name) => { if (!_.isUndefined(options[name])) { opts[name] = options[name]; } }); return opts; }
[ "function", "parseOptions", "(", "options", ")", "{", "let", "opts", "=", "{", "}", ";", "_", ".", "each", "(", "nodecipher", ".", "defaults", ",", "(", "defaultVal", ",", "name", ")", "=>", "{", "if", "(", "!", "_", ".", "isUndefined", "(", "optio...
Parses the command line options into a more consise Object that will be accepted by NodeCipher. @param {Object} options @returns {Object} opts
[ "Parses", "the", "command", "line", "options", "into", "a", "more", "consise", "Object", "that", "will", "be", "accepted", "by", "NodeCipher", "." ]
e35ae0ad48a7907a0abd94a8f31daff0a967334f
https://github.com/nathanbuchar/node-cipher/blob/e35ae0ad48a7907a0abd94a8f31daff0a967334f/bin/actions/cipher.js#L41-L51
train
nathanbuchar/node-cipher
bin/actions/cipher.js
cipher
function cipher(command, input, output, options) { if (_.isUndefined(options.password)) { prompForPassword(password => { cipher(command, input, output, options, _.assign(options, { password })); }); } else { let opts = _.assign(parseOptions(options), { input, output }); nodecipher[command](op...
javascript
function cipher(command, input, output, options) { if (_.isUndefined(options.password)) { prompForPassword(password => { cipher(command, input, output, options, _.assign(options, { password })); }); } else { let opts = _.assign(parseOptions(options), { input, output }); nodecipher[command](op...
[ "function", "cipher", "(", "command", ",", "input", ",", "output", ",", "options", ")", "{", "if", "(", "_", ".", "isUndefined", "(", "options", ".", "password", ")", ")", "{", "prompForPassword", "(", "password", "=>", "{", "cipher", "(", "command", "...
First checks if the password has been supplied. If not, the user is prompted to provide one. Once the password is received, parse the options and then call the appropriate NodeCipher method with the given options. @see prompForPassword @see handleCipher @param {string} command @param {string} input @param {string} out...
[ "First", "checks", "if", "the", "password", "has", "been", "supplied", ".", "If", "not", "the", "user", "is", "prompted", "to", "provide", "one", ".", "Once", "the", "password", "is", "received", "parse", "the", "options", "and", "then", "call", "the", "...
e35ae0ad48a7907a0abd94a8f31daff0a967334f
https://github.com/nathanbuchar/node-cipher/blob/e35ae0ad48a7907a0abd94a8f31daff0a967334f/bin/actions/cipher.js#L65-L77
train
nathanbuchar/node-cipher
bin/actions/cipher.js
handleCipher
function handleCipher(opts, err) { if (err) { switch (err.name) { case nodecipher.errors.BAD_ALGORITHM: handleInvalidAlgorithm(opts, err); break; case nodecipher.errors.BAD_DIGEST: handleInvalidHash(opts, err); break; case nodecipher.errors.BAD_FILE: handl...
javascript
function handleCipher(opts, err) { if (err) { switch (err.name) { case nodecipher.errors.BAD_ALGORITHM: handleInvalidAlgorithm(opts, err); break; case nodecipher.errors.BAD_DIGEST: handleInvalidHash(opts, err); break; case nodecipher.errors.BAD_FILE: handl...
[ "function", "handleCipher", "(", "opts", ",", "err", ")", "{", "if", "(", "err", ")", "{", "switch", "(", "err", ".", "name", ")", "{", "case", "nodecipher", ".", "errors", ".", "BAD_ALGORITHM", ":", "handleInvalidAlgorithm", "(", "opts", ",", "err", "...
Called when the cipher has completed. Handles errors if there are any. @param {Object} opts @param {Error|null} err
[ "Called", "when", "the", "cipher", "has", "completed", ".", "Handles", "errors", "if", "there", "are", "any", "." ]
e35ae0ad48a7907a0abd94a8f31daff0a967334f
https://github.com/nathanbuchar/node-cipher/blob/e35ae0ad48a7907a0abd94a8f31daff0a967334f/bin/actions/cipher.js#L85-L107
train
nathanbuchar/node-cipher
bin/actions/cipher.js
handleEnoentError
function handleEnoentError(opts, err) { console.log(chalk.red( '\nError: ' + err.name + '. "' + err.path + '" does not exist.\n' )); }
javascript
function handleEnoentError(opts, err) { console.log(chalk.red( '\nError: ' + err.name + '. "' + err.path + '" does not exist.\n' )); }
[ "function", "handleEnoentError", "(", "opts", ",", "err", ")", "{", "console", ".", "log", "(", "chalk", ".", "red", "(", "'\\nError: '", "+", "err", ".", "name", "+", "'. \"'", "+", "err", ".", "path", "+", "'\" does not exist.\\n'", ")", ")", ";", "}...
Handles NodeCipher ENOENT errors. @param {Object} opts @param {Error} err
[ "Handles", "NodeCipher", "ENOENT", "errors", "." ]
e35ae0ad48a7907a0abd94a8f31daff0a967334f
https://github.com/nathanbuchar/node-cipher/blob/e35ae0ad48a7907a0abd94a8f31daff0a967334f/bin/actions/cipher.js#L115-L119
train
ghinda/angular-meditor
dist/meditor.js
function () { var toolbarHeight = $toolbar[0].offsetHeight; var toolbarWidth = $toolbar[0].offsetWidth; var spacing = 5; var selection = window.getSelection(); var range = selection.getRangeAt(0); var boundary = range.getBoundingClientRect(); var topPosition = bo...
javascript
function () { var toolbarHeight = $toolbar[0].offsetHeight; var toolbarWidth = $toolbar[0].offsetWidth; var spacing = 5; var selection = window.getSelection(); var range = selection.getRangeAt(0); var boundary = range.getBoundingClientRect(); var topPosition = bo...
[ "function", "(", ")", "{", "var", "toolbarHeight", "=", "$toolbar", "[", "0", "]", ".", "offsetHeight", ";", "var", "toolbarWidth", "=", "$toolbar", "[", "0", "]", ".", "offsetWidth", ";", "var", "spacing", "=", "5", ";", "var", "selection", "=", "wind...
position the toolbar above or below the selected text
[ "position", "the", "toolbar", "above", "or", "below", "the", "selected", "text" ]
97d1873303980d80850e034da128e241903167d7
https://github.com/ghinda/angular-meditor/blob/97d1873303980d80850e034da128e241903167d7/dist/meditor.js#L134-L171
train
ghinda/angular-meditor
dist/meditor.js
function (e) { // if you click something from the toolbar // don't do anything if(e && e.target && $toolbar.find(e.target).length) { return false; } var newSelection = window.getSelection(); // get selection node var anchorNode = newSelection.anchorNo...
javascript
function (e) { // if you click something from the toolbar // don't do anything if(e && e.target && $toolbar.find(e.target).length) { return false; } var newSelection = window.getSelection(); // get selection node var anchorNode = newSelection.anchorNo...
[ "function", "(", "e", ")", "{", "// if you click something from the toolbar", "// don't do anything", "if", "(", "e", "&&", "e", ".", "target", "&&", "$toolbar", ".", "find", "(", "e", ".", "target", ")", ".", "length", ")", "{", "return", "false", ";", "}...
get current selection and act on toolbar depending on it
[ "get", "current", "selection", "and", "act", "on", "toolbar", "depending", "on", "it" ]
97d1873303980d80850e034da128e241903167d7
https://github.com/ghinda/angular-meditor/blob/97d1873303980d80850e034da128e241903167d7/dist/meditor.js#L174-L219
train
ghinda/angular-meditor
dist/meditor.js
function (selection) { var parentNode = selection.anchorNode; if (!parentNode.tagName) { parentNode = selection.anchorNode.parentNode; } var childNode = parentNode.childNodes[0]; if(childNode && childNode.tagName && childNode.tagName.toLowerCase() in generatedTags) {...
javascript
function (selection) { var parentNode = selection.anchorNode; if (!parentNode.tagName) { parentNode = selection.anchorNode.parentNode; } var childNode = parentNode.childNodes[0]; if(childNode && childNode.tagName && childNode.tagName.toLowerCase() in generatedTags) {...
[ "function", "(", "selection", ")", "{", "var", "parentNode", "=", "selection", ".", "anchorNode", ";", "if", "(", "!", "parentNode", ".", "tagName", ")", "{", "parentNode", "=", "selection", ".", "anchorNode", ".", "parentNode", ";", "}", "var", "childNode...
check current selection styles and activate buttons
[ "check", "current", "selection", "styles", "and", "activate", "buttons" ]
97d1873303980d80850e034da128e241903167d7
https://github.com/ghinda/angular-meditor/blob/97d1873303980d80850e034da128e241903167d7/dist/meditor.js#L222-L251
train
Azard/egg-oauth2-server
lib/server.js
replaceResponse
function replaceResponse(res) { // copy for response.headers.hasOwnProperty is undefined case // https://github.com/oauthjs/node-oauth2-server/pull/486 const newResponse = { headers: {}, }; for (const property in res) { if (property !== 'headers') { newResponse[property] = res[property]; } ...
javascript
function replaceResponse(res) { // copy for response.headers.hasOwnProperty is undefined case // https://github.com/oauthjs/node-oauth2-server/pull/486 const newResponse = { headers: {}, }; for (const property in res) { if (property !== 'headers') { newResponse[property] = res[property]; } ...
[ "function", "replaceResponse", "(", "res", ")", "{", "// copy for response.headers.hasOwnProperty is undefined case", "// https://github.com/oauthjs/node-oauth2-server/pull/486", "const", "newResponse", "=", "{", "headers", ":", "{", "}", ",", "}", ";", "for", "(", "const",...
replace response.
[ "replace", "response", "." ]
00f1c7eabdd2357c2b71afe366b356f2347e5f16
https://github.com/Azard/egg-oauth2-server/blob/00f1c7eabdd2357c2b71afe366b356f2347e5f16/lib/server.js#L16-L32
train
krg7880/json-schema-generator
lib/cli/in.js
function(url, callback) { logger('Fetching URL resource: ' + url); request(url, function (error, response, body) { if (!error && response.statusCode == 200) { callback(body); } else { var errorString = [ 'There was an error loading the requested resource', '>>> ' + url ]; if (error) { err...
javascript
function(url, callback) { logger('Fetching URL resource: ' + url); request(url, function (error, response, body) { if (!error && response.statusCode == 200) { callback(body); } else { var errorString = [ 'There was an error loading the requested resource', '>>> ' + url ]; if (error) { err...
[ "function", "(", "url", ",", "callback", ")", "{", "logger", "(", "'Fetching URL resource: '", "+", "url", ")", ";", "request", "(", "url", ",", "function", "(", "error", ",", "response", ",", "body", ")", "{", "if", "(", "!", "error", "&&", "response"...
Fetches a remote JSON document and generate the schema based on the contents of the remote resource. If an output directory is specified, the document will be saved locally. @param {String} url - The location of the remote resource @param {Function} callback
[ "Fetches", "a", "remote", "JSON", "document", "and", "generate", "the", "schema", "based", "on", "the", "contents", "of", "the", "remote", "resource", ".", "If", "an", "output", "directory", "is", "specified", "the", "document", "will", "be", "saved", "local...
27d5a84721c4cd496a2a37bbefda09c07a59f6a1
https://github.com/krg7880/json-schema-generator/blob/27d5a84721c4cd496a2a37bbefda09c07a59f6a1/lib/cli/in.js#L17-L34
train
krg7880/json-schema-generator
lib/cli/in.js
function(filePath, callback) { if (!fs.existsSync(filePath)) { errorHandler("File " + filePath + " does not exist. Please specify a valid path."); } var body = ''; var reader = fs.createReadStream(filePath); reader.on('data', function(chunks) { body += chunks; }).on('end', function() { callback(body); }).o...
javascript
function(filePath, callback) { if (!fs.existsSync(filePath)) { errorHandler("File " + filePath + " does not exist. Please specify a valid path."); } var body = ''; var reader = fs.createReadStream(filePath); reader.on('data', function(chunks) { body += chunks; }).on('end', function() { callback(body); }).o...
[ "function", "(", "filePath", ",", "callback", ")", "{", "if", "(", "!", "fs", ".", "existsSync", "(", "filePath", ")", ")", "{", "errorHandler", "(", "\"File \"", "+", "filePath", "+", "\" does not exist. Please specify a valid path.\"", ")", ";", "}", "var", ...
Reads the specified JSON file from the filesystem which is used to generate the schema. @param {String} filePath - Path to JSON document to load. @param {Function} callback
[ "Reads", "the", "specified", "JSON", "file", "from", "the", "filesystem", "which", "is", "used", "to", "generate", "the", "schema", "." ]
27d5a84721c4cd496a2a37bbefda09c07a59f6a1
https://github.com/krg7880/json-schema-generator/blob/27d5a84721c4cd496a2a37bbefda09c07a59f6a1/lib/cli/in.js#L44-L57
train
krg7880/json-schema-generator
bin/cli.js
getName
function getName(str) { var name = path.basename(str); if (name.lastIndexOf('.') === -1) { name += '.json'; } return name; }
javascript
function getName(str) { var name = path.basename(str); if (name.lastIndexOf('.') === -1) { name += '.json'; } return name; }
[ "function", "getName", "(", "str", ")", "{", "var", "name", "=", "path", ".", "basename", "(", "str", ")", ";", "if", "(", "name", ".", "lastIndexOf", "(", "'.'", ")", "===", "-", "1", ")", "{", "name", "+=", "'.json'", ";", "}", "return", "name"...
Get the name of the JSON resource so the schema matches the source. The .json extension is added if it's missing from the filename. @param {String} str File name @return {String} The name of the file only.
[ "Get", "the", "name", "of", "the", "JSON", "resource", "so", "the", "schema", "matches", "the", "source", ".", "The", ".", "json", "extension", "is", "added", "if", "it", "s", "missing", "from", "the", "filename", "." ]
27d5a84721c4cd496a2a37bbefda09c07a59f6a1
https://github.com/krg7880/json-schema-generator/blob/27d5a84721c4cd496a2a37bbefda09c07a59f6a1/bin/cli.js#L138-L144
train
krg7880/json-schema-generator
lib/cli/out.js
handleOutput
function handleOutput(destConfig, jsonString) { var type = destConfig.type, destPath = destConfig.path, defaultFileName = destConfig.defaultFileName, force = destConfig.force, pretty = destConfig.pretty; if (!type || type === "omit") { // don't even bother return; } if (pretty) { jsonString = prettyD...
javascript
function handleOutput(destConfig, jsonString) { var type = destConfig.type, destPath = destConfig.path, defaultFileName = destConfig.defaultFileName, force = destConfig.force, pretty = destConfig.pretty; if (!type || type === "omit") { // don't even bother return; } if (pretty) { jsonString = prettyD...
[ "function", "handleOutput", "(", "destConfig", ",", "jsonString", ")", "{", "var", "type", "=", "destConfig", ".", "type", ",", "destPath", "=", "destConfig", ".", "path", ",", "defaultFileName", "=", "destConfig", ".", "defaultFileName", ",", "force", "=", ...
Save output to a certain location @param {Object} destConfig @param {String} jsonString
[ "Save", "output", "to", "a", "certain", "location" ]
27d5a84721c4cd496a2a37bbefda09c07a59f6a1
https://github.com/krg7880/json-schema-generator/blob/27d5a84721c4cd496a2a37bbefda09c07a59f6a1/lib/cli/out.js#L53-L76
train
wyattdanger/geocoder
index.js
function ( name, opts ) { if ( ! name ) { return cbk( new Error( "Geocoder.selectProvider requires a name.") ); } this.provider = name; this.providerOpts = opts || {}; this.providerObj = require("./providers/"+name); }
javascript
function ( name, opts ) { if ( ! name ) { return cbk( new Error( "Geocoder.selectProvider requires a name.") ); } this.provider = name; this.providerOpts = opts || {}; this.providerObj = require("./providers/"+name); }
[ "function", "(", "name", ",", "opts", ")", "{", "if", "(", "!", "name", ")", "{", "return", "cbk", "(", "new", "Error", "(", "\"Geocoder.selectProvider requires a name.\"", ")", ")", ";", "}", "this", ".", "provider", "=", "name", ";", "this", ".", "pr...
Selects a webservice provider @param {String} name, required @param {Object} opts, optional @api public
[ "Selects", "a", "webservice", "provider" ]
135df34eba2082f7175c72c8c6f31aab6267d0f8
https://github.com/wyattdanger/geocoder/blob/135df34eba2082f7175c72c8c6f31aab6267d0f8/index.js#L39-L49
train
wyattdanger/geocoder
index.js
function ( loc, cbk, opts ) { if ( ! loc ) { return cbk( new Error( "Geocoder.geocode requires a location.") ); } return this.providerObj.geocode(this.providerOpts, loc, cbk, opts); }
javascript
function ( loc, cbk, opts ) { if ( ! loc ) { return cbk( new Error( "Geocoder.geocode requires a location.") ); } return this.providerObj.geocode(this.providerOpts, loc, cbk, opts); }
[ "function", "(", "loc", ",", "cbk", ",", "opts", ")", "{", "if", "(", "!", "loc", ")", "{", "return", "cbk", "(", "new", "Error", "(", "\"Geocoder.geocode requires a location.\"", ")", ")", ";", "}", "return", "this", ".", "providerObj", ".", "geocode", ...
Request geocoordinates of given `loc` from Google @param {String} loc, required @param {Function} cbk, required @param {Object} opts, optional @api public
[ "Request", "geocoordinates", "of", "given", "loc", "from", "Google" ]
135df34eba2082f7175c72c8c6f31aab6267d0f8
https://github.com/wyattdanger/geocoder/blob/135df34eba2082f7175c72c8c6f31aab6267d0f8/index.js#L60-L68
train
kentcdodds/nps-utils
src/index.js
concurrent
function concurrent(scripts) { const {colors, scripts: quotedScripts, names} = Object.keys(scripts) .reduce(reduceScripts, { colors: [], scripts: [], names: [], }) const flags = [ '--kill-others-on-fail', `--prefix-colors "${colors.join(',')}"`, '--prefix "[{name}]"', `--na...
javascript
function concurrent(scripts) { const {colors, scripts: quotedScripts, names} = Object.keys(scripts) .reduce(reduceScripts, { colors: [], scripts: [], names: [], }) const flags = [ '--kill-others-on-fail', `--prefix-colors "${colors.join(',')}"`, '--prefix "[{name}]"', `--na...
[ "function", "concurrent", "(", "scripts", ")", "{", "const", "{", "colors", ",", "scripts", ":", "quotedScripts", ",", "names", "}", "=", "Object", ".", "keys", "(", "scripts", ")", ".", "reduce", "(", "reduceScripts", ",", "{", "colors", ":", "[", "]"...
A concurrent script object @typedef {Object|string} ConcurrentScript @property {string} script - the command to run @property {string} color - the color to use (see concurrently's docs for valid values) An object of concurrent script objects @typedef {Object.<ConcurrentScript>} ConcurrentScripts Generates a command...
[ "A", "concurrent", "script", "object" ]
b20c1db9dd79945ee255eff27897d26f763dfd98
https://github.com/kentcdodds/nps-utils/blob/b20c1db9dd79945ee255eff27897d26f763dfd98/src/index.js#L112-L148
train
kentcdodds/nps-utils
src/index.js
includePackage
function includePackage(packageNameOrOptions) { const packageScriptsPath = typeof packageNameOrOptions === 'string' ? `./packages/${packageNameOrOptions}/package-scripts.js` : packageNameOrOptions.path const startingDir = process.cwd().split('\\').join('/') const relativeDir = path .relative(startin...
javascript
function includePackage(packageNameOrOptions) { const packageScriptsPath = typeof packageNameOrOptions === 'string' ? `./packages/${packageNameOrOptions}/package-scripts.js` : packageNameOrOptions.path const startingDir = process.cwd().split('\\').join('/') const relativeDir = path .relative(startin...
[ "function", "includePackage", "(", "packageNameOrOptions", ")", "{", "const", "packageScriptsPath", "=", "typeof", "packageNameOrOptions", "===", "'string'", "?", "`", "${", "packageNameOrOptions", "}", "`", ":", "packageNameOrOptions", ".", "path", "const", "starting...
The options to pass to includePackage @typedef {Object|string} IncludePackageOptions @property {string} path - the path to the package scripts Includes the scripts from a sub-package in your repo (for yarn workspaces or lerna style projects). @param {IncludePackageOptions} packageNameOrOptions - either a simple name ...
[ "The", "options", "to", "pass", "to", "includePackage" ]
b20c1db9dd79945ee255eff27897d26f763dfd98
https://github.com/kentcdodds/nps-utils/blob/b20c1db9dd79945ee255eff27897d26f763dfd98/src/index.js#L345-L393
train
kentcdodds/nps-utils
src/index.js
getBin
function getBin(packageName, binName = packageName) { const packagePath = require.resolve(`${packageName}/package.json`) const concurrentlyDir = path.dirname(packagePath) let {bin: binRelativeToPackage} = require(packagePath) if (typeof binRelativeToPackage === 'object') { binRelativeToPackage = binRelative...
javascript
function getBin(packageName, binName = packageName) { const packagePath = require.resolve(`${packageName}/package.json`) const concurrentlyDir = path.dirname(packagePath) let {bin: binRelativeToPackage} = require(packagePath) if (typeof binRelativeToPackage === 'object') { binRelativeToPackage = binRelative...
[ "function", "getBin", "(", "packageName", ",", "binName", "=", "packageName", ")", "{", "const", "packagePath", "=", "require", ".", "resolve", "(", "`", "${", "packageName", "}", "`", ")", "const", "concurrentlyDir", "=", "path", ".", "dirname", "(", "pac...
Get the path to one of the bin scripts exported by a package @param {string} packageName - name of the npm package @param {string} binName=packageName - name of the script @returns {string} path, relative to process.cwd()
[ "Get", "the", "path", "to", "one", "of", "the", "bin", "scripts", "exported", "by", "a", "package" ]
b20c1db9dd79945ee255eff27897d26f763dfd98
https://github.com/kentcdodds/nps-utils/blob/b20c1db9dd79945ee255eff27897d26f763dfd98/src/index.js#L409-L418
train
glenjamin/mocha-multi
mocha-multi.js
done
function done(failures, fn, reportersWithDone, waitFor = identity) { const count = reportersWithDone.length; const waitReporter = waitOn((r, f) => r.done(failures, f)); const progress = v => debug('Awaiting on %j reporters to invoke done callback.', count - v); promiseProgress(reportersWithDone.map(waitReporter...
javascript
function done(failures, fn, reportersWithDone, waitFor = identity) { const count = reportersWithDone.length; const waitReporter = waitOn((r, f) => r.done(failures, f)); const progress = v => debug('Awaiting on %j reporters to invoke done callback.', count - v); promiseProgress(reportersWithDone.map(waitReporter...
[ "function", "done", "(", "failures", ",", "fn", ",", "reportersWithDone", ",", "waitFor", "=", "identity", ")", "{", "const", "count", "=", "reportersWithDone", ".", "length", ";", "const", "waitReporter", "=", "waitOn", "(", "(", "r", ",", "f", ")", "=>...
Override done to allow done processing for any reporters that have a done method.
[ "Override", "done", "to", "allow", "done", "processing", "for", "any", "reporters", "that", "have", "a", "done", "method", "." ]
fdaba56dd70b49b2846decd8fa0aec9c79180899
https://github.com/glenjamin/mocha-multi/blob/fdaba56dd70b49b2846decd8fa0aec9c79180899/mocha-multi.js#L241-L251
train
jeffbski/bench-rest
lib/bench-rest.js
needsSubtitution
function needsSubtitution(prop) { var needsSub = false; if (typeof prop === 'string') { if (prop.indexOf('#{INDEX}') !== -1) needsSub = true; } else if (typeof prop === 'object') { var str = JSON.stringify(prop); if (str.indexOf('#{INDEX}') !== -1) needsSub = true; } return needsSub; }
javascript
function needsSubtitution(prop) { var needsSub = false; if (typeof prop === 'string') { if (prop.indexOf('#{INDEX}') !== -1) needsSub = true; } else if (typeof prop === 'object') { var str = JSON.stringify(prop); if (str.indexOf('#{INDEX}') !== -1) needsSub = true; } return needsSub; }
[ "function", "needsSubtitution", "(", "prop", ")", "{", "var", "needsSub", "=", "false", ";", "if", "(", "typeof", "prop", "===", "'string'", ")", "{", "if", "(", "prop", ".", "indexOf", "(", "'#{INDEX}'", ")", "!==", "-", "1", ")", "needsSub", "=", "...
determines if a property needs substitution @returns boolean true if needs substition
[ "determines", "if", "a", "property", "needs", "substitution" ]
c9f3ee3420bcbabeb3cf650327662a26b0d6497f
https://github.com/jeffbski/bench-rest/blob/c9f3ee3420bcbabeb3cf650327662a26b0d6497f/lib/bench-rest.js#L311-L320
train
jeffbski/bench-rest
lib/bench-rest.js
substituteFnWhereNeeded
function substituteFnWhereNeeded(actions) { actions = actions || []; return actions.map(function (action) { return Object.keys(action).reduce(function (accum, key) { if ((key === 'get' || key === 'head' || key === 'put' || key === 'post' || key === 'del' || key === 'patch') && needsSubtitution(a...
javascript
function substituteFnWhereNeeded(actions) { actions = actions || []; return actions.map(function (action) { return Object.keys(action).reduce(function (accum, key) { if ((key === 'get' || key === 'head' || key === 'put' || key === 'post' || key === 'del' || key === 'patch') && needsSubtitution(a...
[ "function", "substituteFnWhereNeeded", "(", "actions", ")", "{", "actions", "=", "actions", "||", "[", "]", ";", "return", "actions", ".", "map", "(", "function", "(", "action", ")", "{", "return", "Object", ".", "keys", "(", "action", ")", ".", "reduce"...
create modified actions object which has substituteFns for any keys that are using substitution. These substituteFns have one argument `tokens` which will be bound to them in the queuing loop, so at runtime, the fn will be executed and returns the proper value. Keys which do not need substitution, will be returned unt...
[ "create", "modified", "actions", "object", "which", "has", "substituteFns", "for", "any", "keys", "that", "are", "using", "substitution", ".", "These", "substituteFns", "have", "one", "argument", "tokens", "which", "will", "be", "bound", "to", "them", "in", "t...
c9f3ee3420bcbabeb3cf650327662a26b0d6497f
https://github.com/jeffbski/bench-rest/blob/c9f3ee3420bcbabeb3cf650327662a26b0d6497f/lib/bench-rest.js#L335-L358
train
jeffbski/bench-rest
lib/bench-rest.js
bindSubtituteFnsWithTokens
function bindSubtituteFnsWithTokens(actions, tokens) { return actions.map(function (action) { return Object.keys(action).reduce(function (accum, key) { // if it is list of sub keys, and is a fn, then bind with tokens if (SUBSTITUTED_KEYS.indexOf(key) !== -1 && typeof action[key] === 'function') { ...
javascript
function bindSubtituteFnsWithTokens(actions, tokens) { return actions.map(function (action) { return Object.keys(action).reduce(function (accum, key) { // if it is list of sub keys, and is a fn, then bind with tokens if (SUBSTITUTED_KEYS.indexOf(key) !== -1 && typeof action[key] === 'function') { ...
[ "function", "bindSubtituteFnsWithTokens", "(", "actions", ",", "tokens", ")", "{", "return", "actions", ".", "map", "(", "function", "(", "action", ")", "{", "return", "Object", ".", "keys", "(", "action", ")", ".", "reduce", "(", "function", "(", "accum",...
if any of the action properties that allow substitution are fns, then bind the tokens to the fn, so when executed it will have proper value @returns actions with fns bound
[ "if", "any", "of", "the", "action", "properties", "that", "allow", "substitution", "are", "fns", "then", "bind", "the", "tokens", "to", "the", "fn", "so", "when", "executed", "it", "will", "have", "proper", "value" ]
c9f3ee3420bcbabeb3cf650327662a26b0d6497f
https://github.com/jeffbski/bench-rest/blob/c9f3ee3420bcbabeb3cf650327662a26b0d6497f/lib/bench-rest.js#L365-L377
train
jeffbski/bench-rest
lib/bench-rest.js
execAnySubFns
function execAnySubFns(actions) { return actions.map(function (action) { return Object.keys(action).reduce(function (accum, key) { // if it is list of sub keys, and is a fn, then bind with tokens if (SUBSTITUTED_KEYS.indexOf(key) !== -1 && typeof action[key] === 'function') { accum[key] = acti...
javascript
function execAnySubFns(actions) { return actions.map(function (action) { return Object.keys(action).reduce(function (accum, key) { // if it is list of sub keys, and is a fn, then bind with tokens if (SUBSTITUTED_KEYS.indexOf(key) !== -1 && typeof action[key] === 'function') { accum[key] = acti...
[ "function", "execAnySubFns", "(", "actions", ")", "{", "return", "actions", ".", "map", "(", "function", "(", "action", ")", "{", "return", "Object", ".", "keys", "(", "action", ")", ".", "reduce", "(", "function", "(", "accum", ",", "key", ")", "{", ...
If any substitutions need to be done, the properties will be replaced with a fn which has been bound to tokens, so exec the fn and return the value for the property @returns actions with values ready for use
[ "If", "any", "substitutions", "need", "to", "be", "done", "the", "properties", "will", "be", "replaced", "with", "a", "fn", "which", "has", "been", "bound", "to", "tokens", "so", "exec", "the", "fn", "and", "return", "the", "value", "for", "the", "proper...
c9f3ee3420bcbabeb3cf650327662a26b0d6497f
https://github.com/jeffbski/bench-rest/blob/c9f3ee3420bcbabeb3cf650327662a26b0d6497f/lib/bench-rest.js#L385-L397
train
mathew-kurian/Scribe.js
static/lib/autocomplete.js
function(scope, element, attrs, autoCtrl){ element.bind('mouseenter', function() { autoCtrl.preSelect(attrs.val); autoCtrl.setIndex(attrs.index); }); element.bind('mouseleave', function() { autoCtrl.preSelectOff(); }); }
javascript
function(scope, element, attrs, autoCtrl){ element.bind('mouseenter', function() { autoCtrl.preSelect(attrs.val); autoCtrl.setIndex(attrs.index); }); element.bind('mouseleave', function() { autoCtrl.preSelectOff(); }); }
[ "function", "(", "scope", ",", "element", ",", "attrs", ",", "autoCtrl", ")", "{", "element", ".", "bind", "(", "'mouseenter'", ",", "function", "(", ")", "{", "autoCtrl", ".", "preSelect", "(", "attrs", ".", "val", ")", ";", "autoCtrl", ".", "setIndex...
^look for controller on parents element
[ "^look", "for", "controller", "on", "parents", "element" ]
8b5fb7e34e541a661fedcf89c8c910d0f355a11b
https://github.com/mathew-kurian/Scribe.js/blob/8b5fb7e34e541a661fedcf89c8c910d0f355a11b/static/lib/autocomplete.js#L273-L282
train
mathew-kurian/Scribe.js
static/js/services/scribeAPI.js
function (data) { var lines = data.match(/[^\r\n]+/g); //cut lines return lines.map(function (line) { try { return JSON.parse(line); } catch (e) { ret...
javascript
function (data) { var lines = data.match(/[^\r\n]+/g); //cut lines return lines.map(function (line) { try { return JSON.parse(line); } catch (e) { ret...
[ "function", "(", "data", ")", "{", "var", "lines", "=", "data", ".", "match", "(", "/", "[^\\r\\n]+", "/", "g", ")", ";", "//cut lines", "return", "lines", ".", "map", "(", "function", "(", "line", ")", "{", "try", "{", "return", "JSON", ".", "pars...
As logs are lines of JSON, we want to parse each lines one by one
[ "As", "logs", "are", "lines", "of", "JSON", "we", "want", "to", "parse", "each", "lines", "one", "by", "one" ]
8b5fb7e34e541a661fedcf89c8c910d0f355a11b
https://github.com/mathew-kurian/Scribe.js/blob/8b5fb7e34e541a661fedcf89c8c910d0f355a11b/static/js/services/scribeAPI.js#L37-L48
train
linkedin/sepia
src/cache.js
playback
function playback(resHeaders, resBody) { if (!forceLive) { var headerContent = fs.readFileSync(filename + '.headers'); resHeaders = JSON.parse(headerContent); } var socket = new EventEmitter(); socket.setTimeout = socket.setEncoding = function() {}; // Needed...
javascript
function playback(resHeaders, resBody) { if (!forceLive) { var headerContent = fs.readFileSync(filename + '.headers'); resHeaders = JSON.parse(headerContent); } var socket = new EventEmitter(); socket.setTimeout = socket.setEncoding = function() {}; // Needed...
[ "function", "playback", "(", "resHeaders", ",", "resBody", ")", "{", "if", "(", "!", "forceLive", ")", "{", "var", "headerContent", "=", "fs", ".", "readFileSync", "(", "filename", "+", "'.headers'", ")", ";", "resHeaders", "=", "JSON", ".", "parse", "("...
Only called if either the fixture with the constructed filename exists, or we're playing back passed in data.
[ "Only", "called", "if", "either", "the", "fixture", "with", "the", "constructed", "filename", "exists", "or", "we", "re", "playing", "back", "passed", "in", "data", "." ]
96e2093462d8229da271b5862008aa625d0fe048
https://github.com/linkedin/sepia/blob/96e2093462d8229da271b5862008aa625d0fe048/src/cache.js#L88-L136
train
gustavohenke/bselect
src/bselect.js
function( arg ) { var listItems, listItem, i, len, results; var options = _callMethod( this, "option" ); var searched = arg instanceof $.Event ? arg.target.value : arg; var bselect = _callMethod( this, "element" ); if ( this[ 0 ].disabled ) { ...
javascript
function( arg ) { var listItems, listItem, i, len, results; var options = _callMethod( this, "option" ); var searched = arg instanceof $.Event ? arg.target.value : arg; var bselect = _callMethod( this, "element" ); if ( this[ 0 ].disabled ) { ...
[ "function", "(", "arg", ")", "{", "var", "listItems", ",", "listItem", ",", "i", ",", "len", ",", "results", ";", "var", "options", "=", "_callMethod", "(", "this", ",", "\"option\"", ")", ";", "var", "searched", "=", "arg", "instanceof", "$", ".", "...
Searches every item in the list for the given text
[ "Searches", "every", "item", "in", "the", "list", "for", "the", "given", "text" ]
8ee485e3ef24e9498f9e32aac4a424a864a1eb99
https://github.com/gustavohenke/bselect/blob/8ee485e3ef24e9498f9e32aac4a424a864a1eb99/src/bselect.js#L182-L230
train
gustavohenke/bselect
src/bselect.js
function() { var bselect = _callMethod( this, "element" ); var optionList = bselect.find( ".bselect-option-list" ).empty(); var mapping = {}; var i = 0; bselect.toggleClass( "disabled", this.prop( "disabled" ) ); this.find( "option, > opt...
javascript
function() { var bselect = _callMethod( this, "element" ); var optionList = bselect.find( ".bselect-option-list" ).empty(); var mapping = {}; var i = 0; bselect.toggleClass( "disabled", this.prop( "disabled" ) ); this.find( "option, > opt...
[ "function", "(", ")", "{", "var", "bselect", "=", "_callMethod", "(", "this", ",", "\"element\"", ")", ";", "var", "optionList", "=", "bselect", ".", "find", "(", "\".bselect-option-list\"", ")", ".", "empty", "(", ")", ";", "var", "mapping", "=", "{", ...
Refreshes the option list. Useful when new HTML is added
[ "Refreshes", "the", "option", "list", ".", "Useful", "when", "new", "HTML", "is", "added" ]
8ee485e3ef24e9498f9e32aac4a424a864a1eb99
https://github.com/gustavohenke/bselect/blob/8ee485e3ef24e9498f9e32aac4a424a864a1eb99/src/bselect.js#L265-L317
train
gustavohenke/bselect
src/bselect.js
adjustDropdownHeight
function adjustDropdownHeight( $elem ) { var list = $elem.find( ".bselect-option-list" ); var len = list.find( "li:visible" ).length; list.innerHeight( parseInt( list.css( "line-height" ), 10 ) * 1.5 * ( len < 5 ? len : 5 ) ); }
javascript
function adjustDropdownHeight( $elem ) { var list = $elem.find( ".bselect-option-list" ); var len = list.find( "li:visible" ).length; list.innerHeight( parseInt( list.css( "line-height" ), 10 ) * 1.5 * ( len < 5 ? len : 5 ) ); }
[ "function", "adjustDropdownHeight", "(", "$elem", ")", "{", "var", "list", "=", "$elem", ".", "find", "(", "\".bselect-option-list\"", ")", ";", "var", "len", "=", "list", ".", "find", "(", "\"li:visible\"", ")", ".", "length", ";", "list", ".", "innerHeig...
Adjusts the dropdown height of an bselect.
[ "Adjusts", "the", "dropdown", "height", "of", "an", "bselect", "." ]
8ee485e3ef24e9498f9e32aac4a424a864a1eb99
https://github.com/gustavohenke/bselect/blob/8ee485e3ef24e9498f9e32aac4a424a864a1eb99/src/bselect.js#L360-L365
train
gustavohenke/bselect
src/bselect.js
updateOptions
function updateOptions( $elem, prev, curr ) { var bselect = _callMethod( $elem, "element" ); $.each( prev, function(key, val) { if ( curr[ key ] !== val ) { if ( key === "size" ) { var sizes = $.map( bootstrapButtonSizes.slice( 0 ), function( size )...
javascript
function updateOptions( $elem, prev, curr ) { var bselect = _callMethod( $elem, "element" ); $.each( prev, function(key, val) { if ( curr[ key ] !== val ) { if ( key === "size" ) { var sizes = $.map( bootstrapButtonSizes.slice( 0 ), function( size )...
[ "function", "updateOptions", "(", "$elem", ",", "prev", ",", "curr", ")", "{", "var", "bselect", "=", "_callMethod", "(", "$elem", ",", "\"element\"", ")", ";", "$", ".", "each", "(", "prev", ",", "function", "(", "key", ",", "val", ")", "{", "if", ...
Updates visual properties of the bselect after the plugin was initialized
[ "Updates", "visual", "properties", "of", "the", "bselect", "after", "the", "plugin", "was", "initialized" ]
8ee485e3ef24e9498f9e32aac4a424a864a1eb99
https://github.com/gustavohenke/bselect/blob/8ee485e3ef24e9498f9e32aac4a424a864a1eb99/src/bselect.js#L368-L385
train
gustavohenke/bselect
src/bselect.js
showNoOptionsAvailable
function showNoOptionsAvailable( $elem ) { var bselect = _callMethod( $elem, "element" ); bselect.find( ".bselect-message" ).text( $.bselect.i18n.noOptionsAvailable ).show(); }
javascript
function showNoOptionsAvailable( $elem ) { var bselect = _callMethod( $elem, "element" ); bselect.find( ".bselect-message" ).text( $.bselect.i18n.noOptionsAvailable ).show(); }
[ "function", "showNoOptionsAvailable", "(", "$elem", ")", "{", "var", "bselect", "=", "_callMethod", "(", "$elem", ",", "\"element\"", ")", ";", "bselect", ".", "find", "(", "\".bselect-message\"", ")", ".", "text", "(", "$", ".", "bselect", ".", "i18n", "....
Show the 'no options available' message
[ "Show", "the", "no", "options", "available", "message" ]
8ee485e3ef24e9498f9e32aac4a424a864a1eb99
https://github.com/gustavohenke/bselect/blob/8ee485e3ef24e9498f9e32aac4a424a864a1eb99/src/bselect.js#L388-L391
train
gustavohenke/bselect
src/bselect.js
setup
function setup( elem, options ) { var caret, label, container, id, dropdown; var $elem = $( elem ); // First of, let's build the base HTML of BSelect id = ++elements; container = $( "<div class='bselect' />", { id: "bselect-" + id }); dropd...
javascript
function setup( elem, options ) { var caret, label, container, id, dropdown; var $elem = $( elem ); // First of, let's build the base HTML of BSelect id = ++elements; container = $( "<div class='bselect' />", { id: "bselect-" + id }); dropd...
[ "function", "setup", "(", "elem", ",", "options", ")", "{", "var", "caret", ",", "label", ",", "container", ",", "id", ",", "dropdown", ";", "var", "$elem", "=", "$", "(", "elem", ")", ";", "// First of, let's build the base HTML of BSelect\r", "id", "=", ...
Run all the setup stuff
[ "Run", "all", "the", "setup", "stuff" ]
8ee485e3ef24e9498f9e32aac4a424a864a1eb99
https://github.com/gustavohenke/bselect/blob/8ee485e3ef24e9498f9e32aac4a424a864a1eb99/src/bselect.js#L438-L526
train
hex7c0/mongodb-restore
index.js
someCollections
function someCollections(db, collections, next) { var last = ~~collections.length, counter = 0; if (last === 0) { // empty set return next(null); } collections.forEach(function(collection) { db.collection(collection, function(err, collection) { logger('select collection ' + collection.collecti...
javascript
function someCollections(db, collections, next) { var last = ~~collections.length, counter = 0; if (last === 0) { // empty set return next(null); } collections.forEach(function(collection) { db.collection(collection, function(err, collection) { logger('select collection ' + collection.collecti...
[ "function", "someCollections", "(", "db", ",", "collections", ",", "next", ")", "{", "var", "last", "=", "~", "~", "collections", ".", "length", ",", "counter", "=", "0", ";", "if", "(", "last", "===", "0", ")", "{", "// empty set", "return", "next", ...
drop data from some collections @function someCollections @param {Object} db - database @param {Array} collections - selected collections @param {Function} next - callback
[ "drop", "data", "from", "some", "collections" ]
f67183bd8fcff89ce9bf2ccc79ab8691488d7667
https://github.com/hex7c0/mongodb-restore/blob/f67183bd8fcff89ce9bf2ccc79ab8691488d7667/index.js#L304-L328
train
prescottprue/firebase-ci
src/actions/mapEnv.js
strFromEnvironmentVarSetting
function strFromEnvironmentVarSetting(functionsVar, envVar) { if (!process.env[envVar]) { const msg = `${envVar} does not exist on within environment variables` warn(msg) return '' } return `${functionsVar}="${process.env[envVar]}"` }
javascript
function strFromEnvironmentVarSetting(functionsVar, envVar) { if (!process.env[envVar]) { const msg = `${envVar} does not exist on within environment variables` warn(msg) return '' } return `${functionsVar}="${process.env[envVar]}"` }
[ "function", "strFromEnvironmentVarSetting", "(", "functionsVar", ",", "envVar", ")", "{", "if", "(", "!", "process", ".", "env", "[", "envVar", "]", ")", "{", "const", "msg", "=", "`", "${", "envVar", "}", "`", "warn", "(", "msg", ")", "return", "''", ...
Build a string from mapEnv setting @param {String} functionsVar - Name of variable within functions @param {String} envVar - Variable within environment
[ "Build", "a", "string", "from", "mapEnv", "setting" ]
e447765549678b6f72acd58b179d629a0cfa0b58
https://github.com/prescottprue/firebase-ci/blob/e447765549678b6f72acd58b179d629a0cfa0b58/src/actions/mapEnv.js#L16-L23
train
prescottprue/firebase-ci
src/actions/mapEnv.js
createConfigSetString
function createConfigSetString(mapEnvSettings) { const settingsStrsArr = map(mapEnvSettings, strFromEnvironmentVarSetting) const settingsStr = compact(settingsStrsArr).join(' ') // Get project from passed options, falling back to branch name const projectKey = getProjectKey(mapEnvSettings) return `firebase fu...
javascript
function createConfigSetString(mapEnvSettings) { const settingsStrsArr = map(mapEnvSettings, strFromEnvironmentVarSetting) const settingsStr = compact(settingsStrsArr).join(' ') // Get project from passed options, falling back to branch name const projectKey = getProjectKey(mapEnvSettings) return `firebase fu...
[ "function", "createConfigSetString", "(", "mapEnvSettings", ")", "{", "const", "settingsStrsArr", "=", "map", "(", "mapEnvSettings", ",", "strFromEnvironmentVarSetting", ")", "const", "settingsStr", "=", "compact", "(", "settingsStrsArr", ")", ".", "join", "(", "' '...
Combine all functions config sets from mapEnv settings in .firebaserc to a single functions config set command string. @param {Object} mapEnvSettings - Settings for mapping environment
[ "Combine", "all", "functions", "config", "sets", "from", "mapEnv", "settings", "in", ".", "firebaserc", "to", "a", "single", "functions", "config", "set", "command", "string", "." ]
e447765549678b6f72acd58b179d629a0cfa0b58
https://github.com/prescottprue/firebase-ci/blob/e447765549678b6f72acd58b179d629a0cfa0b58/src/actions/mapEnv.js#L30-L36
train
philbooth/complexity-report
src/index.js
mergeResults
function mergeResults(jsRes, coffeeRes) { if (!coffeeRes) { return jsRes; } jsRes.reports = jsRes.reports.concat(coffeeRes.reports); return escomplex.processResults(jsRes, cli.nocoresize || false); }
javascript
function mergeResults(jsRes, coffeeRes) { if (!coffeeRes) { return jsRes; } jsRes.reports = jsRes.reports.concat(coffeeRes.reports); return escomplex.processResults(jsRes, cli.nocoresize || false); }
[ "function", "mergeResults", "(", "jsRes", ",", "coffeeRes", ")", "{", "if", "(", "!", "coffeeRes", ")", "{", "return", "jsRes", ";", "}", "jsRes", ".", "reports", "=", "jsRes", ".", "reports", ".", "concat", "(", "coffeeRes", ".", "reports", ")", ";", ...
merge the array of reports together and rerun through the code to compute aggregates
[ "merge", "the", "array", "of", "reports", "together", "and", "rerun", "through", "the", "code", "to", "compute", "aggregates" ]
5cbedd6138bbce74c0b87d4293fbb077e7c9dc2b
https://github.com/philbooth/complexity-report/blob/5cbedd6138bbce74c0b87d4293fbb077e7c9dc2b/src/index.js#L271-L279
train
thrackle/express-zip
lib/express-zip.js
function(file, cb) { zip.entry(fs.createReadStream(file.path), { name: file.name }, cb); }
javascript
function(file, cb) { zip.entry(fs.createReadStream(file.path), { name: file.name }, cb); }
[ "function", "(", "file", ",", "cb", ")", "{", "zip", ".", "entry", "(", "fs", ".", "createReadStream", "(", "file", ".", "path", ")", ",", "{", "name", ":", "file", ".", "name", "}", ",", "cb", ")", ";", "}" ]
res is a writable stream
[ "res", "is", "a", "writable", "stream" ]
07ca4acce0835e164d202fdd474ca85914ce8b70
https://github.com/thrackle/express-zip/blob/07ca4acce0835e164d202fdd474ca85914ce8b70/lib/express-zip.js#L54-L56
train
request/aws-sign
index.js
hmacSha1
function hmacSha1 (options) { return crypto.createHmac('sha1', options.secret).update(options.message).digest('base64') }
javascript
function hmacSha1 (options) { return crypto.createHmac('sha1', options.secret).update(options.message).digest('base64') }
[ "function", "hmacSha1", "(", "options", ")", "{", "return", "crypto", ".", "createHmac", "(", "'sha1'", ",", "options", ".", "secret", ")", ".", "update", "(", "options", ".", "message", ")", ".", "digest", "(", "'base64'", ")", "}" ]
Simple HMAC-SHA1 Wrapper @param {Object} options @return {String} @api private
[ "Simple", "HMAC", "-", "SHA1", "Wrapper" ]
7a31c117c9a6e03e44b73895c170b7af14d21c38
https://github.com/request/aws-sign/blob/7a31c117c9a6e03e44b73895c170b7af14d21c38/index.js#L71-L73
train
jonathantneal/posthtml-inline-assets
.tape.js
readFile
function readFile(file) { return new Promise( (resolve, reject) => { fs.readFile( file, 'utf8', (error, contents) => { if (error) { reject(error); } else { // console.log('readFile', [file, contents]); resolve(contents); } } ) } ); }
javascript
function readFile(file) { return new Promise( (resolve, reject) => { fs.readFile( file, 'utf8', (error, contents) => { if (error) { reject(error); } else { // console.log('readFile', [file, contents]); resolve(contents); } } ) } ); }
[ "function", "readFile", "(", "file", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "fs", ".", "readFile", "(", "file", ",", "'utf8'", ",", "(", "error", ",", "contents", ")", "=>", "{", "if", "(", "error"...
promises the contents of a file
[ "promises", "the", "contents", "of", "a", "file" ]
dc29fb59327dbdc90f72904518d3258410d54776
https://github.com/jonathantneal/posthtml-inline-assets/blob/dc29fb59327dbdc90f72904518d3258410d54776/.tape.js#L212-L227
train
jonathantneal/posthtml-inline-assets
.tape.js
writeFile
function writeFile(file, contents) { return new Promise( (resolve, reject) => { fs.writeFile( file, contents, error => { if (error) { reject(error); } else { // console.log('writeFile', [file, contents]); resolve(contents); } } ) } ); }
javascript
function writeFile(file, contents) { return new Promise( (resolve, reject) => { fs.writeFile( file, contents, error => { if (error) { reject(error); } else { // console.log('writeFile', [file, contents]); resolve(contents); } } ) } ); }
[ "function", "writeFile", "(", "file", ",", "contents", ")", "{", "return", "new", "Promise", "(", "(", "resolve", ",", "reject", ")", "=>", "{", "fs", ".", "writeFile", "(", "file", ",", "contents", ",", "error", "=>", "{", "if", "(", "error", ")", ...
promises contents written to a file
[ "promises", "contents", "written", "to", "a", "file" ]
dc29fb59327dbdc90f72904518d3258410d54776
https://github.com/jonathantneal/posthtml-inline-assets/blob/dc29fb59327dbdc90f72904518d3258410d54776/.tape.js#L230-L245
train
jonschlinkert/write
index.js
writeFile
function writeFile(filepath, data, options, cb) { if (typeof options === 'function') { cb = options; options = {}; } if (typeof cb !== 'function') { return writeFile.promise.apply(null, arguments); } if (typeof filepath !== 'string') { cb(new TypeError('expected filepath to be a string')); ...
javascript
function writeFile(filepath, data, options, cb) { if (typeof options === 'function') { cb = options; options = {}; } if (typeof cb !== 'function') { return writeFile.promise.apply(null, arguments); } if (typeof filepath !== 'string') { cb(new TypeError('expected filepath to be a string')); ...
[ "function", "writeFile", "(", "filepath", ",", "data", ",", "options", ",", "cb", ")", "{", "if", "(", "typeof", "options", "===", "'function'", ")", "{", "cb", "=", "options", ";", "options", "=", "{", "}", ";", "}", "if", "(", "typeof", "cb", "!=...
Asynchronously writes data to a file, replacing the file if it already exists and creating any intermediate directories if they don't already exist. Data can be a string or a buffer. Returns a promise if a callback function is not passed. ```js var writeFile = require('write'); writeFile('foo.txt', 'This is content......
[ "Asynchronously", "writes", "data", "to", "a", "file", "replacing", "the", "file", "if", "it", "already", "exists", "and", "creating", "any", "intermediate", "directories", "if", "they", "don", "t", "already", "exist", ".", "Data", "can", "be", "a", "string"...
12fc942ba6cea79989f1cd08dd1516e271e0e89a
https://github.com/jonschlinkert/write/blob/12fc942ba6cea79989f1cd08dd1516e271e0e89a/index.js#L40-L68
train
sabertooth-io/web-bluetooth
lib/errorHandler.js
errorHandler
function errorHandler(errorKey, nativeError, alternate) { const errorMessages = { add_characteristic_exists_error: `Characteristic ${alternate} already exists.`, characteristic_error: `Characteristic ${alternate} not found. Add ${alternate} to device using addCharacteristic or try another characteristic.`, conn...
javascript
function errorHandler(errorKey, nativeError, alternate) { const errorMessages = { add_characteristic_exists_error: `Characteristic ${alternate} already exists.`, characteristic_error: `Characteristic ${alternate} not found. Add ${alternate} to device using addCharacteristic or try another characteristic.`, conn...
[ "function", "errorHandler", "(", "errorKey", ",", "nativeError", ",", "alternate", ")", "{", "const", "errorMessages", "=", "{", "add_characteristic_exists_error", ":", "`", "${", "alternate", "}", "`", ",", "characteristic_error", ":", "`", "${", "alternate", "...
errorHandler - Consolodates error message configuration and logic @param {string} errorKey - maps to a detailed error message @param {object} nativeError - the native API error object, if present @param {} alternate -
[ "errorHandler", "-", "Consolodates", "error", "message", "configuration", "and", "logic" ]
ab1ec47fdd13dc992a9093d12443a258b47718db
https://github.com/sabertooth-io/web-bluetooth/blob/ab1ec47fdd13dc992a9093d12443a258b47718db/lib/errorHandler.js#L8-L43
train
webdeveloperpr/draft-js-custom-styles
build/index.js
styleFn
function styleFn(prefix, cssProp) { return function (style) { if (!style.size) { return {}; } var value = style.filter(function (val) { return val.startsWith(prefix); }).first(); if (value) { var newVal = value.replace(prefix, ''); return _defineProperty({}, (0, _lodash2.de...
javascript
function styleFn(prefix, cssProp) { return function (style) { if (!style.size) { return {}; } var value = style.filter(function (val) { return val.startsWith(prefix); }).first(); if (value) { var newVal = value.replace(prefix, ''); return _defineProperty({}, (0, _lodash2.de...
[ "function", "styleFn", "(", "prefix", ",", "cssProp", ")", "{", "return", "function", "(", "style", ")", "{", "if", "(", "!", "style", ".", "size", ")", "{", "return", "{", "}", ";", "}", "var", "value", "=", "style", ".", "filter", "(", "function"...
style is an OrderedSet type
[ "style", "is", "an", "OrderedSet", "type" ]
f3e6b533905de8eee6da54f9727b5e5803d53fc4
https://github.com/webdeveloperpr/draft-js-custom-styles/blob/f3e6b533905de8eee6da54f9727b5e5803d53fc4/build/index.js#L167-L181
train
Robinyo/ionic-angular-schematics
src/utility/find-module.js
findModuleFromOptions
function findModuleFromOptions(host, options) { if (options.hasOwnProperty('skipImport') && options.skipImport) { return undefined; } if (!options.module) { const pathToCheck = (options.sourceDir || '') + '/' + (options.path || '') + (options.flat ? '' : '/' + strings_1.dasherize...
javascript
function findModuleFromOptions(host, options) { if (options.hasOwnProperty('skipImport') && options.skipImport) { return undefined; } if (!options.module) { const pathToCheck = (options.sourceDir || '') + '/' + (options.path || '') + (options.flat ? '' : '/' + strings_1.dasherize...
[ "function", "findModuleFromOptions", "(", "host", ",", "options", ")", "{", "if", "(", "options", ".", "hasOwnProperty", "(", "'skipImport'", ")", "&&", "options", ".", "skipImport", ")", "{", "return", "undefined", ";", "}", "if", "(", "!", "options", "."...
Find the module referred by a set of options passed to the schematics.
[ "Find", "the", "module", "referred", "by", "a", "set", "of", "options", "passed", "to", "the", "schematics", "." ]
2f8fdcf5c95713516212d8cbd4a30f64e96fae7a
https://github.com/Robinyo/ionic-angular-schematics/blob/2f8fdcf5c95713516212d8cbd4a30f64e96fae7a/src/utility/find-module.js#L15-L43
train
Robinyo/ionic-angular-schematics
src/utility/find-module.js
findModule
function findModule(host, generateDir) { let dir = host.getDir('/' + generateDir); const moduleRe = /\.module\.ts$/; const routingModuleRe = /-routing\.module\.ts/; while (dir) { const matches = dir.subfiles.filter(p => moduleRe.test(p) && !routingModuleRe.test(p)); if (matches.length ==...
javascript
function findModule(host, generateDir) { let dir = host.getDir('/' + generateDir); const moduleRe = /\.module\.ts$/; const routingModuleRe = /-routing\.module\.ts/; while (dir) { const matches = dir.subfiles.filter(p => moduleRe.test(p) && !routingModuleRe.test(p)); if (matches.length ==...
[ "function", "findModule", "(", "host", ",", "generateDir", ")", "{", "let", "dir", "=", "host", ".", "getDir", "(", "'/'", "+", "generateDir", ")", ";", "const", "moduleRe", "=", "/", "\\.module\\.ts$", "/", ";", "const", "routingModuleRe", "=", "/", "-r...
Function to find the "closest" module to a generated file's path.
[ "Function", "to", "find", "the", "closest", "module", "to", "a", "generated", "file", "s", "path", "." ]
2f8fdcf5c95713516212d8cbd4a30f64e96fae7a
https://github.com/Robinyo/ionic-angular-schematics/blob/2f8fdcf5c95713516212d8cbd4a30f64e96fae7a/src/utility/find-module.js#L48-L65
train
Robinyo/ionic-angular-schematics
src/utility/find-module.js
buildRelativePath
function buildRelativePath(from, to) { from = core_1.normalize(from); to = core_1.normalize(to); // Convert to arrays. const fromParts = from.split('/'); const toParts = to.split('/'); // Remove file names (preserving destination) fromParts.pop(); const toFileName = toParts.pop(); co...
javascript
function buildRelativePath(from, to) { from = core_1.normalize(from); to = core_1.normalize(to); // Convert to arrays. const fromParts = from.split('/'); const toParts = to.split('/'); // Remove file names (preserving destination) fromParts.pop(); const toFileName = toParts.pop(); co...
[ "function", "buildRelativePath", "(", "from", ",", "to", ")", "{", "from", "=", "core_1", ".", "normalize", "(", "from", ")", ";", "to", "=", "core_1", ".", "normalize", "(", "to", ")", ";", "// Convert to arrays.", "const", "fromParts", "=", "from", "."...
Build a relative path from one file path to another file path.
[ "Build", "a", "relative", "path", "from", "one", "file", "path", "to", "another", "file", "path", "." ]
2f8fdcf5c95713516212d8cbd4a30f64e96fae7a
https://github.com/Robinyo/ionic-angular-schematics/blob/2f8fdcf5c95713516212d8cbd4a30f64e96fae7a/src/utility/find-module.js#L70-L92
train
Niryo/controllerim
src/Observer/mobxReactClone.js
getPreciseType
function getPreciseType(propValue) { var propType = getPropType(propValue); if (propType === 'object') { if (propValue instanceof Date) { return 'date'; } else if (propValue instanceof RegExp) { return 'regexp'; } } retu...
javascript
function getPreciseType(propValue) { var propType = getPropType(propValue); if (propType === 'object') { if (propValue instanceof Date) { return 'date'; } else if (propValue instanceof RegExp) { return 'regexp'; } } retu...
[ "function", "getPreciseType", "(", "propValue", ")", "{", "var", "propType", "=", "getPropType", "(", "propValue", ")", ";", "if", "(", "propType", "===", "'object'", ")", "{", "if", "(", "propValue", "instanceof", "Date", ")", "{", "return", "'date'", ";"...
This handles more types than `getPropType`. Only used for error messages. Copied from React.PropTypes
[ "This", "handles", "more", "types", "than", "getPropType", ".", "Only", "used", "for", "error", "messages", ".", "Copied", "from", "React", ".", "PropTypes" ]
551640bb2e42279a087832006d1534603288de89
https://github.com/Niryo/controllerim/blob/551640bb2e42279a087832006d1534603288de89/src/Observer/mobxReactClone.js#L366-L376
train
theisensanders-wf/responsive-sketchpad
responsive-sketchpad.js
setCanvasSize
function setCanvasSize (width, height) { canvas.setAttribute('width', width); canvas.setAttribute('height', height); canvas.style.width = width + 'px'; canvas.style.height = height + 'px'; }
javascript
function setCanvasSize (width, height) { canvas.setAttribute('width', width); canvas.setAttribute('height', height); canvas.style.width = width + 'px'; canvas.style.height = height + 'px'; }
[ "function", "setCanvasSize", "(", "width", ",", "height", ")", "{", "canvas", ".", "setAttribute", "(", "'width'", ",", "width", ")", ";", "canvas", ".", "setAttribute", "(", "'height'", ",", "height", ")", ";", "canvas", ".", "style", ".", "width", "=",...
Set the size of canvas
[ "Set", "the", "size", "of", "canvas" ]
aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f
https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L56-L61
train
theisensanders-wf/responsive-sketchpad
responsive-sketchpad.js
getPointRelativeToCanvas
function getPointRelativeToCanvas (point) { return { x: point.x / canvas.width, y: point.y / canvas.height }; }
javascript
function getPointRelativeToCanvas (point) { return { x: point.x / canvas.width, y: point.y / canvas.height }; }
[ "function", "getPointRelativeToCanvas", "(", "point", ")", "{", "return", "{", "x", ":", "point", ".", "x", "/", "canvas", ".", "width", ",", "y", ":", "point", ".", "y", "/", "canvas", ".", "height", "}", ";", "}" ]
Returns a points x,y locations relative to the size of the canvase
[ "Returns", "a", "points", "x", "y", "locations", "relative", "to", "the", "size", "of", "the", "canvase" ]
aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f
https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L80-L85
train
theisensanders-wf/responsive-sketchpad
responsive-sketchpad.js
getCursorRelativeToCanvas
function getCursorRelativeToCanvas (e) { var cur = {}; if (isTouchEvent(e)) { cur.x = e.touches[0].pageX - canvas.offsetLeft; cur.y = e.touches[0].pageY - canvas.offsetTop; } else { var rect = that.canvas.getBoundingClientRect(); ...
javascript
function getCursorRelativeToCanvas (e) { var cur = {}; if (isTouchEvent(e)) { cur.x = e.touches[0].pageX - canvas.offsetLeft; cur.y = e.touches[0].pageY - canvas.offsetTop; } else { var rect = that.canvas.getBoundingClientRect(); ...
[ "function", "getCursorRelativeToCanvas", "(", "e", ")", "{", "var", "cur", "=", "{", "}", ";", "if", "(", "isTouchEvent", "(", "e", ")", ")", "{", "cur", ".", "x", "=", "e", ".", "touches", "[", "0", "]", ".", "pageX", "-", "canvas", ".", "offset...
Get location of the cursor in the canvas
[ "Get", "location", "of", "the", "cursor", "in", "the", "canvas" ]
aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f
https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L97-L110
train
theisensanders-wf/responsive-sketchpad
responsive-sketchpad.js
clearCanvas
function clearCanvas () { context.clearRect(0, 0, canvas.width, canvas.height); if (opts.backgroundColor) { context.fillStyle = opts.backgroundColor; context.fillRect(0, 0, canvas.width, canvas.height); } }
javascript
function clearCanvas () { context.clearRect(0, 0, canvas.width, canvas.height); if (opts.backgroundColor) { context.fillStyle = opts.backgroundColor; context.fillRect(0, 0, canvas.width, canvas.height); } }
[ "function", "clearCanvas", "(", ")", "{", "context", ".", "clearRect", "(", "0", ",", "0", ",", "canvas", ".", "width", ",", "canvas", ".", "height", ")", ";", "if", "(", "opts", ".", "backgroundColor", ")", "{", "context", ".", "fillStyle", "=", "op...
Erase everything in the canvase
[ "Erase", "everything", "in", "the", "canvase" ]
aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f
https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L123-L130
train
theisensanders-wf/responsive-sketchpad
responsive-sketchpad.js
normalizePoint
function normalizePoint (point) { return { x: point.x * canvas.width, y: point.y * canvas.height }; }
javascript
function normalizePoint (point) { return { x: point.x * canvas.width, y: point.y * canvas.height }; }
[ "function", "normalizePoint", "(", "point", ")", "{", "return", "{", "x", ":", "point", ".", "x", "*", "canvas", ".", "width", ",", "y", ":", "point", ".", "y", "*", "canvas", ".", "height", "}", ";", "}" ]
Since points are stored relative to the size of the canvas this takes a point and converts it to actual x, y distances in the canvas
[ "Since", "points", "are", "stored", "relative", "to", "the", "size", "of", "the", "canvas", "this", "takes", "a", "point", "and", "converts", "it", "to", "actual", "x", "y", "distances", "in", "the", "canvas" ]
aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f
https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L136-L141
train
theisensanders-wf/responsive-sketchpad
responsive-sketchpad.js
drawStroke
function drawStroke (stroke) { context.beginPath(); for (var j = 0; j < stroke.points.length - 1; j++) { var start = normalizePoint(stroke.points[j]); var end = normalizePoint(stroke.points[j + 1]); context.moveTo(start.x, start.y); ...
javascript
function drawStroke (stroke) { context.beginPath(); for (var j = 0; j < stroke.points.length - 1; j++) { var start = normalizePoint(stroke.points[j]); var end = normalizePoint(stroke.points[j + 1]); context.moveTo(start.x, start.y); ...
[ "function", "drawStroke", "(", "stroke", ")", "{", "context", ".", "beginPath", "(", ")", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "stroke", ".", "points", ".", "length", "-", "1", ";", "j", "++", ")", "{", "var", "start", "=", "no...
Draw a stroke on the canvas
[ "Draw", "a", "stroke", "on", "the", "canvas" ]
aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f
https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L155-L173
train
theisensanders-wf/responsive-sketchpad
responsive-sketchpad.js
redraw
function redraw () { clearCanvas(); for (var i = 0; i < that.strokes.length; i++) { drawStroke(that.strokes[i]); } }
javascript
function redraw () { clearCanvas(); for (var i = 0; i < that.strokes.length; i++) { drawStroke(that.strokes[i]); } }
[ "function", "redraw", "(", ")", "{", "clearCanvas", "(", ")", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "that", ".", "strokes", ".", "length", ";", "i", "++", ")", "{", "drawStroke", "(", "that", ".", "strokes", "[", "i", "]", ")", ...
Redraw the canvas
[ "Redraw", "the", "canvas" ]
aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f
https://github.com/theisensanders-wf/responsive-sketchpad/blob/aedc4d2aa710cc75e48e0df49aeff9b49e51ad5f/responsive-sketchpad.js#L178-L184
train