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
signalfx/signalfx-nodejs
lib/proto/signal_fx_protocol_buffers_pb2.js
EventUploadMessage
function EventUploadMessage(properties) { this.events = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) ...
javascript
function EventUploadMessage(properties) { this.events = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) ...
[ "function", "EventUploadMessage", "(", "properties", ")", "{", "this", ".", "events", "=", "[", "]", ";", "if", "(", "properties", ")", "for", "(", "var", "keys", "=", "Object", ".", "keys", "(", "properties", ")", ",", "i", "=", "0", ";", "i", "<"...
Properties of an EventUploadMessage. @memberof com.signalfx.metrics.protobuf @interface IEventUploadMessage @property {Array.<com.signalfx.metrics.protobuf.IEvent>|null} [events] EventUploadMessage events Constructs a new EventUploadMessage. @memberof com.signalfx.metrics.protobuf @classdesc Represents an EventUpload...
[ "Properties", "of", "an", "EventUploadMessage", "." ]
88f14af02c9af8de54e3ff273b5c9d3ab32030de
https://github.com/signalfx/signalfx-nodejs/blob/88f14af02c9af8de54e3ff273b5c9d3ab32030de/lib/proto/signal_fx_protocol_buffers_pb2.js#L2218-L2224
train
signalfx/signalfx-nodejs
lib/client/signalflow/message_router.js
getRoutedMessageHandler
function getRoutedMessageHandler(params, onMessage, onError, isRetryPatchMode) { var expectedBatchMessageCount = 0; var numBatchesDetermined = false; var messageBatchBuffer = []; var lastSeenDataTime = 0; var lastSeenDataBatchTime = 0; function composeDataBatches(dataArray) { if (dataArray.length === 0...
javascript
function getRoutedMessageHandler(params, onMessage, onError, isRetryPatchMode) { var expectedBatchMessageCount = 0; var numBatchesDetermined = false; var messageBatchBuffer = []; var lastSeenDataTime = 0; var lastSeenDataBatchTime = 0; function composeDataBatches(dataArray) { if (dataArray.length === 0...
[ "function", "getRoutedMessageHandler", "(", "params", ",", "onMessage", ",", "onError", ",", "isRetryPatchMode", ")", "{", "var", "expectedBatchMessageCount", "=", "0", ";", "var", "numBatchesDetermined", "=", "false", ";", "var", "messageBatchBuffer", "=", "[", "...
a routed message handler deals with all messages within a particular channel scope it is responsible for massaging messages and flushing batches of data messages.
[ "a", "routed", "message", "handler", "deals", "with", "all", "messages", "within", "a", "particular", "channel", "scope", "it", "is", "responsible", "for", "massaging", "messages", "and", "flushing", "batches", "of", "data", "messages", "." ]
88f14af02c9af8de54e3ff273b5c9d3ab32030de
https://github.com/signalfx/signalfx-nodejs/blob/88f14af02c9af8de54e3ff273b5c9d3ab32030de/lib/client/signalflow/message_router.js#L8-L102
train
defunctzombie/node-browser-resolve
index.js
load_shims_sync
function load_shims_sync(paths, browser) { // identify if our file should be replaced per the browser field // original filename|id -> replacement var shims = Object.create(null); var cur_path; while (cur_path = paths.shift()) { var pkg_path = path.join(cur_path, 'package.json'); t...
javascript
function load_shims_sync(paths, browser) { // identify if our file should be replaced per the browser field // original filename|id -> replacement var shims = Object.create(null); var cur_path; while (cur_path = paths.shift()) { var pkg_path = path.join(cur_path, 'package.json'); t...
[ "function", "load_shims_sync", "(", "paths", ",", "browser", ")", "{", "// identify if our file should be replaced per the browser field", "// original filename|id -> replacement", "var", "shims", "=", "Object", ".", "create", "(", "null", ")", ";", "var", "cur_path", ";"...
paths is mutated synchronously load shims from first package.json file found
[ "paths", "is", "mutated", "synchronously", "load", "shims", "from", "first", "package", ".", "json", "file", "found" ]
427bb886cc22cc773651d3f2a51d4c5ea455870e
https://github.com/defunctzombie/node-browser-resolve/blob/427bb886cc22cc773651d3f2a51d4c5ea455870e/index.js#L121-L146
train
exonum/exonum-client
src/types/hexadecimal.js
hexTypeFactory
function hexTypeFactory (serizalizer, size, name) { return Object.defineProperties({}, { size: { get: () => () => size, enumerable: true }, name: { get: () => name, enumerable: true }, serialize: { get: () => serizalizer } }) }
javascript
function hexTypeFactory (serizalizer, size, name) { return Object.defineProperties({}, { size: { get: () => () => size, enumerable: true }, name: { get: () => name, enumerable: true }, serialize: { get: () => serizalizer } }) }
[ "function", "hexTypeFactory", "(", "serizalizer", ",", "size", ",", "name", ")", "{", "return", "Object", ".", "defineProperties", "(", "{", "}", ",", "{", "size", ":", "{", "get", ":", "(", ")", "=>", "(", ")", "=>", "size", ",", "enumerable", ":", ...
Factory for building Hex Types @param {function(value, buffer, from)} serizalizer function accepting value, buffer, position and returns modified buffer @param {number} size type size in bytes @param {string} name type name to distinguish between types @returns {Object} hex type
[ "Factory", "for", "building", "Hex", "Types" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/types/hexadecimal.js#L49-L63
train
exonum/exonum-client
src/types/hexadecimal.js
Uuid
function Uuid (validator, serializer, factory) { const size = 16 const name = 'Uuid' function cleaner (value) { return String(value).replace(/-/g, '') } validator = validator.bind(null, name, size) serializer = serializer((value) => validator(cleaner(value))) return factory(serializer, size, name) ...
javascript
function Uuid (validator, serializer, factory) { const size = 16 const name = 'Uuid' function cleaner (value) { return String(value).replace(/-/g, '') } validator = validator.bind(null, name, size) serializer = serializer((value) => validator(cleaner(value))) return factory(serializer, size, name) ...
[ "function", "Uuid", "(", "validator", ",", "serializer", ",", "factory", ")", "{", "const", "size", "=", "16", "const", "name", "=", "'Uuid'", "function", "cleaner", "(", "value", ")", "{", "return", "String", "(", "value", ")", ".", "replace", "(", "/...
Uuid type factory @param {function(name, size, value)} validator hexadecimal validator @param {function(validator, value, buffer, from)} encoder function accepting validator, value, buffer, position and returns modified buffer @param {function(serizalizer, size, name)} factory type builder factory @returns {Object} he...
[ "Uuid", "type", "factory" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/types/hexadecimal.js#L87-L99
train
exonum/exonum-client
src/types/hexadecimal.js
Hash
function Hash (validator, serializer, factory) { const size = HASH_LENGTH const name = 'Hash' validator = validator.bind(null, name, size) serializer = serializer(validator) const hasher = function (value) { return validator(value) && value } return Object.defineProperty(factory(serializer, size, n...
javascript
function Hash (validator, serializer, factory) { const size = HASH_LENGTH const name = 'Hash' validator = validator.bind(null, name, size) serializer = serializer(validator) const hasher = function (value) { return validator(value) && value } return Object.defineProperty(factory(serializer, size, n...
[ "function", "Hash", "(", "validator", ",", "serializer", ",", "factory", ")", "{", "const", "size", "=", "HASH_LENGTH", "const", "name", "=", "'Hash'", "validator", "=", "validator", ".", "bind", "(", "null", ",", "name", ",", "size", ")", "serializer", ...
Hash type factory @param {function(name, size, value)} validator hexadecimal validator @param {function(validator, value, buffer, from)} encoder function accepting validator, value, buffer, position and returns modified buffer @param {function(serizalizer, size, name)} factory type builder factory @returns {Object} he...
[ "Hash", "type", "factory" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/types/hexadecimal.js#L110-L126
train
exonum/exonum-client
src/types/hexadecimal.js
Digest
function Digest (validator, serializer, factory) { const size = 64 const name = 'Digest' validator = validator.bind(null, name, size) serializer = serializer(validator) return factory(serializer, size, name) }
javascript
function Digest (validator, serializer, factory) { const size = 64 const name = 'Digest' validator = validator.bind(null, name, size) serializer = serializer(validator) return factory(serializer, size, name) }
[ "function", "Digest", "(", "validator", ",", "serializer", ",", "factory", ")", "{", "const", "size", "=", "64", "const", "name", "=", "'Digest'", "validator", "=", "validator", ".", "bind", "(", "null", ",", "name", ",", "size", ")", "serializer", "=", ...
Digest type factory @param {function(name, size, value)} validator hexadecimal validator @param {function(validator, value, buffer, from)} encoder function accepting validator, value, buffer, position and returns modified buffer @param {function(serizalizer, size, name)} factory type builder factory @returns {Object} ...
[ "Digest", "type", "factory" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/types/hexadecimal.js#L137-L145
train
exonum/exonum-client
src/types/hexadecimal.js
PublicKey
function PublicKey (validator, serializer, factory) { const size = PUBLIC_KEY_LENGTH const name = 'PublicKey' validator = validator.bind(null, name, size) serializer = serializer(validator) return factory(serializer, size, name) }
javascript
function PublicKey (validator, serializer, factory) { const size = PUBLIC_KEY_LENGTH const name = 'PublicKey' validator = validator.bind(null, name, size) serializer = serializer(validator) return factory(serializer, size, name) }
[ "function", "PublicKey", "(", "validator", ",", "serializer", ",", "factory", ")", "{", "const", "size", "=", "PUBLIC_KEY_LENGTH", "const", "name", "=", "'PublicKey'", "validator", "=", "validator", ".", "bind", "(", "null", ",", "name", ",", "size", ")", ...
PublicKey type factory @param {function(name, size, value)} validator hexadecimal validator @param {function(validator, value, buffer, from)} encoder function accepting validator, value, buffer, position and returns modified buffer @param {function(serizalizer, size, name)} factory type builder factory @returns {Objec...
[ "PublicKey", "type", "factory" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/types/hexadecimal.js#L156-L164
train
exonum/exonum-client
src/types/primitive.js
insertIntegerToByteArray
function insertIntegerToByteArray (number, buffer, from, size) { let value = bigInt(number) // convert a number-like object into a big integer for (let pos = 0; pos < size; pos++) { const divmod = value.divmod(256) buffer[from + pos] = divmod.remainder.toJSNumber() value = divmod.quotient } return...
javascript
function insertIntegerToByteArray (number, buffer, from, size) { let value = bigInt(number) // convert a number-like object into a big integer for (let pos = 0; pos < size; pos++) { const divmod = value.divmod(256) buffer[from + pos] = divmod.remainder.toJSNumber() value = divmod.quotient } return...
[ "function", "insertIntegerToByteArray", "(", "number", ",", "buffer", ",", "from", ",", "size", ")", "{", "let", "value", "=", "bigInt", "(", "number", ")", "// convert a number-like object into a big integer", "for", "(", "let", "pos", "=", "0", ";", "pos", "...
Insert number into array as as little-endian @param {number|bigInt} number @param {Array} buffer @param {number} from @param {number} size @returns {boolean}
[ "Insert", "number", "into", "array", "as", "as", "little", "-", "endian" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/types/primitive.js#L15-L25
train
exonum/exonum-client
src/blockchain/merkle.js
calcHeight
function calcHeight (count) { let i = 0 while (bigInt(2).pow(i).lt(count)) { i++ } return i }
javascript
function calcHeight (count) { let i = 0 while (bigInt(2).pow(i).lt(count)) { i++ } return i }
[ "function", "calcHeight", "(", "count", ")", "{", "let", "i", "=", "0", "while", "(", "bigInt", "(", "2", ")", ".", "pow", "(", "i", ")", ".", "lt", "(", "count", ")", ")", "{", "i", "++", "}", "return", "i", "}" ]
Calculate height of merkle tree @param {bigInt} count @return {number}
[ "Calculate", "height", "of", "merkle", "tree" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/blockchain/merkle.js#L13-L19
train
exonum/exonum-client
src/blockchain/merkle.js
getHash
function getHash (data, depth, index) { let element let elementsHash if (depth !== 0 && (depth + 1) !== height) { throw new Error('Value node is on wrong height in tree.') } if (start.gt(index) || end.lt(index)) { throw new Error('Wrong index of value node.') } if (start.plus(...
javascript
function getHash (data, depth, index) { let element let elementsHash if (depth !== 0 && (depth + 1) !== height) { throw new Error('Value node is on wrong height in tree.') } if (start.gt(index) || end.lt(index)) { throw new Error('Wrong index of value node.') } if (start.plus(...
[ "function", "getHash", "(", "data", ",", "depth", ",", "index", ")", "{", "let", "element", "let", "elementsHash", "if", "(", "depth", "!==", "0", "&&", "(", "depth", "+", "1", ")", "!==", "height", ")", "{", "throw", "new", "Error", "(", "'Value nod...
Get value from node, insert into elements array and return its hash @param data @param {number} depth @param {number} index @returns {string}
[ "Get", "value", "from", "node", "insert", "into", "elements", "array", "and", "return", "its", "hash" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/blockchain/merkle.js#L41-L84
train
exonum/exonum-client
src/blockchain/merkle.js
recursive
function recursive (node, depth, index) { let hashLeft let hashRight let summingBuffer // case with single node in tree if (depth === 0 && node.val !== undefined) { return getHash(node.val, depth, index * 2) } if (node.left === undefined) { throw new Error('Left node is missed....
javascript
function recursive (node, depth, index) { let hashLeft let hashRight let summingBuffer // case with single node in tree if (depth === 0 && node.val !== undefined) { return getHash(node.val, depth, index * 2) } if (node.left === undefined) { throw new Error('Left node is missed....
[ "function", "recursive", "(", "node", ",", "depth", ",", "index", ")", "{", "let", "hashLeft", "let", "hashRight", "let", "summingBuffer", "// case with single node in tree", "if", "(", "depth", "===", "0", "&&", "node", ".", "val", "!==", "undefined", ")", ...
Recursive tree traversal function @param {Object} node @param {number} depth @param {number} index @returns {string}
[ "Recursive", "tree", "traversal", "function" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/blockchain/merkle.js#L93-L155
train
exonum/exonum-client
src/blockchain/ProofPath.js
setBit
function setBit (buffer, pos, bit) { const byte = Math.floor(pos / 8) const bitPos = pos % 8 if (bit === 0) { const mask = 255 - (1 << bitPos) buffer[byte] &= mask } else { const mask = (1 << bitPos) buffer[byte] |= mask } }
javascript
function setBit (buffer, pos, bit) { const byte = Math.floor(pos / 8) const bitPos = pos % 8 if (bit === 0) { const mask = 255 - (1 << bitPos) buffer[byte] &= mask } else { const mask = (1 << bitPos) buffer[byte] |= mask } }
[ "function", "setBit", "(", "buffer", ",", "pos", ",", "bit", ")", "{", "const", "byte", "=", "Math", ".", "floor", "(", "pos", "/", "8", ")", "const", "bitPos", "=", "pos", "%", "8", "if", "(", "bit", "===", "0", ")", "{", "const", "mask", "=",...
Sets a specified bit in the byte buffer. @param {Uint8Array} buffer @param {number} pos 0-based position in the buffer to set @param {0 | 1} bit
[ "Sets", "a", "specified", "bit", "in", "the", "byte", "buffer", "." ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/blockchain/ProofPath.js#L167-L178
train
exonum/exonum-client
src/blockchain/table.js
serializeKey
function serializeKey (serviceId, tableIndex) { let buffer = [] Uint16.serialize(serviceId, buffer, buffer.length) Uint16.serialize(tableIndex, buffer, buffer.length) return buffer }
javascript
function serializeKey (serviceId, tableIndex) { let buffer = [] Uint16.serialize(serviceId, buffer, buffer.length) Uint16.serialize(tableIndex, buffer, buffer.length) return buffer }
[ "function", "serializeKey", "(", "serviceId", ",", "tableIndex", ")", "{", "let", "buffer", "=", "[", "]", "Uint16", ".", "serialize", "(", "serviceId", ",", "buffer", ",", "buffer", ".", "length", ")", "Uint16", ".", "serialize", "(", "tableIndex", ",", ...
Serialization table key @param {number} serviceId @param {number} tableIndex @returns {Array}
[ "Serialization", "table", "key" ]
edb77abe6479b7e13c667b2f00aa2dca97d4c401
https://github.com/exonum/exonum-client/blob/edb77abe6479b7e13c667b2f00aa2dca97d4c401/src/blockchain/table.js#L12-L17
train
mercadolibre/chico
dist/ui/chico.js
setAsyncContent
function setAsyncContent(event) { that._content.innerHTML = event.response; /** * Event emitted when the content change. * @event ch.Content#contentchange * @private */ that.emit('_contentchange'); /** * ...
javascript
function setAsyncContent(event) { that._content.innerHTML = event.response; /** * Event emitted when the content change. * @event ch.Content#contentchange * @private */ that.emit('_contentchange'); /** * ...
[ "function", "setAsyncContent", "(", "event", ")", "{", "that", ".", "_content", ".", "innerHTML", "=", "event", ".", "response", ";", "/**\n * Event emitted when the content change.\n * @event ch.Content#contentchange\n * @private\n */"...
Set async content into component's container and emits the current event. @private
[ "Set", "async", "content", "into", "component", "s", "container", "and", "emits", "the", "current", "event", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L181-L219
train
mercadolibre/chico
dist/ui/chico.js
setContent
function setContent(content) { if (content.nodeType !== undefined) { that._content.innerHTML = ''; that._content.appendChild(content); } else { that._content.innerHTML = content; } that._options.cache = true; ...
javascript
function setContent(content) { if (content.nodeType !== undefined) { that._content.innerHTML = ''; that._content.appendChild(content); } else { that._content.innerHTML = content; } that._options.cache = true; ...
[ "function", "setContent", "(", "content", ")", "{", "if", "(", "content", ".", "nodeType", "!==", "undefined", ")", "{", "that", ".", "_content", ".", "innerHTML", "=", "''", ";", "that", ".", "_content", ".", "appendChild", "(", "content", ")", ";", "...
Set content into component's container and emits the contentdone event. @private
[ "Set", "content", "into", "component", "s", "container", "and", "emits", "the", "contentdone", "event", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L225-L254
train
mercadolibre/chico
dist/ui/chico.js
getAsyncContent
function getAsyncContent(url, options) { var requestCfg; // Initial options to be merged with the user's options options = tiny.extend({ 'method': 'GET', 'params': '', 'waiting': '<div class="ch-loading-large"></div>' }, def...
javascript
function getAsyncContent(url, options) { var requestCfg; // Initial options to be merged with the user's options options = tiny.extend({ 'method': 'GET', 'params': '', 'waiting': '<div class="ch-loading-large"></div>' }, def...
[ "function", "getAsyncContent", "(", "url", ",", "options", ")", "{", "var", "requestCfg", ";", "// Initial options to be merged with the user's options", "options", "=", "tiny", ".", "extend", "(", "{", "'method'", ":", "'GET'", ",", "'params'", ":", "''", ",", ...
Get async content with given URL. @private
[ "Get", "async", "content", "with", "given", "URL", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L260-L310
train
mercadolibre/chico
dist/ui/chico.js
Positioner
function Positioner(options) { if (options === undefined) { throw new window.Error('ch.Positioner: Expected options defined.'); } // Creates its private options this._options = tiny.clone(this._defaults); // Init this._configure(options); }
javascript
function Positioner(options) { if (options === undefined) { throw new window.Error('ch.Positioner: Expected options defined.'); } // Creates its private options this._options = tiny.clone(this._defaults); // Init this._configure(options); }
[ "function", "Positioner", "(", "options", ")", "{", "if", "(", "options", "===", "undefined", ")", "{", "throw", "new", "window", ".", "Error", "(", "'ch.Positioner: Expected options defined.'", ")", ";", "}", "// Creates its private options", "this", ".", "_optio...
The Positioner lets you position elements on the screen and changes its positions. @memberof ch @constructor @param {Object} options Configuration object. @param {String} options.target A HTMLElement that reference to the element to be positioned. @param {String} [options.reference] A HTMLElement that it's a reference ...
[ "The", "Positioner", "lets", "you", "position", "elements", "on", "the", "screen", "and", "changes", "its", "positions", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L1030-L1041
train
mercadolibre/chico
dist/ui/chico.js
function (shortcut, name, callback) { if (this._collection[name] === undefined) { this._collection[name] = {}; } if (this._collection[name][shortcut] === undefined) { this._collection[name][shortcut] = []; } ...
javascript
function (shortcut, name, callback) { if (this._collection[name] === undefined) { this._collection[name] = {}; } if (this._collection[name][shortcut] === undefined) { this._collection[name][shortcut] = []; } ...
[ "function", "(", "shortcut", ",", "name", ",", "callback", ")", "{", "if", "(", "this", ".", "_collection", "[", "name", "]", "===", "undefined", ")", "{", "this", ".", "_collection", "[", "name", "]", "=", "{", "}", ";", "}", "if", "(", "this", ...
Add a callback to a shortcut with given name. @param {(ch.onkeybackspace | ch.onkeytab | ch.onkeyenter | ch.onkeyesc | ch.onkeyleftarrow | ch.onkeyuparrow | ch.onkeyrightarrow | ch.onkeydownarrow)} shortcut Shortcut to subscribe. @param {String} name A name to add in the collection. @param {Function} callback A given f...
[ "Add", "a", "callback", "to", "a", "shortcut", "with", "given", "name", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L1308-L1322
train
mercadolibre/chico
dist/ui/chico.js
function (name, shortcut, callback) { var evt, evtCollection, evtCollectionLenght; if (name === undefined) { throw new Error('Shortcuts - "remove(name, shortcut, callback)": "name" parameter must be defined.'); ...
javascript
function (name, shortcut, callback) { var evt, evtCollection, evtCollectionLenght; if (name === undefined) { throw new Error('Shortcuts - "remove(name, shortcut, callback)": "name" parameter must be defined.'); ...
[ "function", "(", "name", ",", "shortcut", ",", "callback", ")", "{", "var", "evt", ",", "evtCollection", ",", "evtCollectionLenght", ";", "if", "(", "name", "===", "undefined", ")", "{", "throw", "new", "Error", "(", "'Shortcuts - \"remove(name, shortcut, callba...
Removes a callback from a shortcut with given name. @param {String} name A name to remove from the collection. @param {(ch.onkeybackspace | ch.onkeytab | ch.onkeyenter | ch.onkeyesc | ch.onkeyleftarrow | ch.onkeyuparrow | ch.onkeyrightarrow | ch.onkeydownarrow)} [shortcut] Shortcut to unsubscribe. @param {Function} cal...
[ "Removes", "a", "callback", "from", "a", "shortcut", "with", "given", "name", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L1334-L1366
train
mercadolibre/chico
dist/ui/chico.js
Tooltip
function Tooltip(el, options) { // TODO: Review what's going on here with options /* if (options === undefined && el !== undefined && el.nodeType !== undefined) { options = el; el = undefined; } */ options = tiny.extend(tiny.clone(this._defaults)...
javascript
function Tooltip(el, options) { // TODO: Review what's going on here with options /* if (options === undefined && el !== undefined && el.nodeType !== undefined) { options = el; el = undefined; } */ options = tiny.extend(tiny.clone(this._defaults)...
[ "function", "Tooltip", "(", "el", ",", "options", ")", "{", "// TODO: Review what's going on here with options", "/*\n if (options === undefined && el !== undefined && el.nodeType !== undefined) {\n options = el;\n el = undefined;\n }\n */", "options", ...
Improves the native tooltips. @memberof ch @constructor @augments ch.Popover @param {HTMLElement} el A HTMLElement to create an instance of ch.Tooltip. @param {Object} [options] Options to customize an instance. @param {String} [options.addClass] CSS class names that will be added to the container on the component init...
[ "Improves", "the", "native", "tooltips", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L4562-L4575
train
mercadolibre/chico
dist/ui/chico.js
Transition
function Transition(el, options) { if (el === undefined || options === undefined) { options = {}; } options.content = (function () { var dummyElement = document.createElement('div'), content = options.waiting || ''; // TODO: options.content ...
javascript
function Transition(el, options) { if (el === undefined || options === undefined) { options = {}; } options.content = (function () { var dummyElement = document.createElement('div'), content = options.waiting || ''; // TODO: options.content ...
[ "function", "Transition", "(", "el", ",", "options", ")", "{", "if", "(", "el", "===", "undefined", "||", "options", "===", "undefined", ")", "{", "options", "=", "{", "}", ";", "}", "options", ".", "content", "=", "(", "function", "(", ")", "{", "...
Transition lets you give feedback to the users when their have to wait for an action. @memberof ch @constructor @augments ch.Popover @param {HTMLElement} [el] A HTMLElement to create an instance of ch.Transition. @param {Object} [options] Options to customize an instance. @param {String} [options.addClass] CSS class na...
[ "Transition", "lets", "you", "give", "feedback", "to", "the", "users", "when", "their", "have", "to", "wait", "for", "an", "action", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L5038-L5065
train
mercadolibre/chico
dist/ui/chico.js
Countdown
function Countdown(el, options) { /** * Reference to context of an instance. * @type {Object} * @private */ var that = this; this._init(el, options); if (this.initialize !== undefined) { /** * If you define an initialize met...
javascript
function Countdown(el, options) { /** * Reference to context of an instance. * @type {Object} * @private */ var that = this; this._init(el, options); if (this.initialize !== undefined) { /** * If you define an initialize met...
[ "function", "Countdown", "(", "el", ",", "options", ")", "{", "/**\n * Reference to context of an instance.\n * @type {Object}\n * @private\n */", "var", "that", "=", "this", ";", "this", ".", "_init", "(", "el", ",", "options", ")", ";", ...
Countdown counts the maximum of characters that user can enter in a form control. Countdown could limit the possibility to continue inserting charset. @memberof ch @constructor @augments ch.Component @param {HTMLElement} el A HTMLElement to create an instance of ch.Countdown. @param {Object} [options] Options to custom...
[ "Countdown", "counts", "the", "maximum", "of", "characters", "that", "user", "can", "enter", "in", "a", "form", "control", ".", "Countdown", "could", "limit", "the", "possibility", "to", "continue", "inserting", "charset", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/ui/chico.js#L8405-L8435
train
mercadolibre/chico
dist/mobile/chico.js
cancelPointerOnScroll
function cancelPointerOnScroll() { function blockPointer() { ch.pointerCanceled = true; function unblockPointer() { ch.pointerCanceled = false; } tiny.once(document, 'touchend', unblockPointer); } tiny.on(document, 'touchmove', ...
javascript
function cancelPointerOnScroll() { function blockPointer() { ch.pointerCanceled = true; function unblockPointer() { ch.pointerCanceled = false; } tiny.once(document, 'touchend', unblockPointer); } tiny.on(document, 'touchmove', ...
[ "function", "cancelPointerOnScroll", "(", ")", "{", "function", "blockPointer", "(", ")", "{", "ch", ".", "pointerCanceled", "=", "true", ";", "function", "unblockPointer", "(", ")", "{", "ch", ".", "pointerCanceled", "=", "false", ";", "}", "tiny", ".", "...
Cancel pointers if the user scroll. @name cancelPointerOnScroll
[ "Cancel", "pointers", "if", "the", "user", "scroll", "." ]
97fe3013b12281728d479c1eb63ea5b8f65dc39b
https://github.com/mercadolibre/chico/blob/97fe3013b12281728d479c1eb63ea5b8f65dc39b/dist/mobile/chico.js#L130-L143
train
stefanocudini/bootstrap-list-filter
bootstrap-list-filter.src.js
tmpl
function tmpl(str, data) { return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) { return data[key] || ''; }); }
javascript
function tmpl(str, data) { return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) { return data[key] || ''; }); }
[ "function", "tmpl", "(", "str", ",", "data", ")", "{", "return", "str", ".", "replace", "(", "/", "\\{ *([\\w_]+) *\\}", "/", "g", ",", "function", "(", "str", ",", "key", ")", "{", "return", "data", "[", "key", "]", "||", "''", ";", "}", ")", ";...
last callData execution
[ "last", "callData", "execution" ]
2df9986d71bfbd252b10f6d5384e4bdf9c12f803
https://github.com/stefanocudini/bootstrap-list-filter/blob/2df9986d71bfbd252b10f6d5384e4bdf9c12f803/bootstrap-list-filter.src.js#L30-L34
train
jaredhanson/passport-oauth1
lib/strategy.js
OAuthStrategy
function OAuthStrategy(options, verify) { if (typeof options == 'function') { verify = options; options = undefined; } options = options || {}; if (!verify) { throw new TypeError('OAuthStrategy requires a verify callback'); } if (!options.requestTokenURL) { throw new TypeError('OAuthStrategy requir...
javascript
function OAuthStrategy(options, verify) { if (typeof options == 'function') { verify = options; options = undefined; } options = options || {}; if (!verify) { throw new TypeError('OAuthStrategy requires a verify callback'); } if (!options.requestTokenURL) { throw new TypeError('OAuthStrategy requir...
[ "function", "OAuthStrategy", "(", "options", ",", "verify", ")", "{", "if", "(", "typeof", "options", "==", "'function'", ")", "{", "verify", "=", "options", ";", "options", "=", "undefined", ";", "}", "options", "=", "options", "||", "{", "}", ";", "i...
Creates an instance of `OAuthStrategy`. The OAuth authentication strategy authenticates requests using the OAuth protocol. OAuth provides a facility for delegated authentication, whereby users can authenticate using a third-party service such as Twitter. Delegating in this manner involves a sequence of events, inclu...
[ "Creates", "an", "instance", "of", "OAuthStrategy", "." ]
6e54eb376863bb7369722275cac10cff72684f0e
https://github.com/jaredhanson/passport-oauth1/blob/6e54eb376863bb7369722275cac10cff72684f0e/lib/strategy.js#L72-L105
train
adrai/node-cqrs-saga
lib/definitions/saga.js
function (sagaStore) { if (!sagaStore || !_.isObject(sagaStore)) { var err = new Error('Please pass a valid sagaStore!'); debug(err); throw err; } this.sagaStore = sagaStore; }
javascript
function (sagaStore) { if (!sagaStore || !_.isObject(sagaStore)) { var err = new Error('Please pass a valid sagaStore!'); debug(err); throw err; } this.sagaStore = sagaStore; }
[ "function", "(", "sagaStore", ")", "{", "if", "(", "!", "sagaStore", "||", "!", "_", ".", "isObject", "(", "sagaStore", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid sagaStore!'", ")", ";", "debug", "(", "err", ")", ";", ...
Injects the needed sagaStore. @param {Object} sagaStore The sagaStore object to inject.
[ "Injects", "the", "needed", "sagaStore", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/definitions/saga.js#L104-L111
train
adrai/node-cqrs-saga
lib/definitions/saga.js
function (cmds, callback) { if (!cmds || cmds.length === 0) { return callback(null); } var self = this; async.each(cmds, function (cmd, fn) { if (dotty.exists(cmd, self.definitions.command.id)) { return fn(null); } self.getNewId(function (err, id) { if (err) { ...
javascript
function (cmds, callback) { if (!cmds || cmds.length === 0) { return callback(null); } var self = this; async.each(cmds, function (cmd, fn) { if (dotty.exists(cmd, self.definitions.command.id)) { return fn(null); } self.getNewId(function (err, id) { if (err) { ...
[ "function", "(", "cmds", ",", "callback", ")", "{", "if", "(", "!", "cmds", "||", "cmds", ".", "length", "===", "0", ")", "{", "return", "callback", "(", "null", ")", ";", "}", "var", "self", "=", "this", ";", "async", ".", "each", "(", "cmds", ...
Checks if the passed commands have a command id. If not it will generate a new one and extend the command with it. @param {Array} cmds The passed commands array. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Checks", "if", "the", "passed", "commands", "have", "a", "command", "id", ".", "If", "not", "it", "will", "generate", "a", "new", "one", "and", "extend", "the", "command", "with", "it", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/definitions/saga.js#L131-L151
train
adrai/node-cqrs-saga
lib/definitions/saga.js
function (evt) { for (var i = 0, len = this.containingProperties.length; i < len; i++) { var prop = this.containingProperties[i]; if (!dotty.exists(evt, prop)) { return false; } } return true; }
javascript
function (evt) { for (var i = 0, len = this.containingProperties.length; i < len; i++) { var prop = this.containingProperties[i]; if (!dotty.exists(evt, prop)) { return false; } } return true; }
[ "function", "(", "evt", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "this", ".", "containingProperties", ".", "length", ";", "i", "<", "len", ";", "i", "++", ")", "{", "var", "prop", "=", "this", ".", "containingProperties", "[", ...
Returns true if the passed event contains all requested properties. @param {Object} evt The passed event. @returns {boolean}
[ "Returns", "true", "if", "the", "passed", "event", "contains", "all", "requested", "properties", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/definitions/saga.js#L158-L166
train
adrai/node-cqrs-saga
lib/definitions/saga.js
function (fn) { if (!fn || !_.isFunction(fn)) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } if (fn.length === 3) { this.shouldHandle = fn; return this; } this.shouldHandle = function (evt, saga, callback) { callback(null, fn(ev...
javascript
function (fn) { if (!fn || !_.isFunction(fn)) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } if (fn.length === 3) { this.shouldHandle = fn; return this; } this.shouldHandle = function (evt, saga, callback) { callback(null, fn(ev...
[ "function", "(", "fn", ")", "{", "if", "(", "!", "fn", "||", "!", "_", ".", "isFunction", "(", "fn", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid function!'", ")", ";", "debug", "(", "err", ")", ";", "throw", "err", ...
Inject shouldHandle function. @param {Function} fn The function to be injected. @returns {Saga} to be able to chain...
[ "Inject", "shouldHandle", "function", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/definitions/saga.js#L416-L453
train
adrai/node-cqrs-saga
lib/revisionGuard.js
function (evt, revInStore, callback) { var evtId = dotty.get(evt, this.definition.id); var revInEvt = dotty.get(evt, this.definition.revision); var self = this; var concatenatedId = this.getConcatenatedId(evt); this.store.set(concatenatedId, revInEvt + 1, revInStore, function (err) { if (er...
javascript
function (evt, revInStore, callback) { var evtId = dotty.get(evt, this.definition.id); var revInEvt = dotty.get(evt, this.definition.revision); var self = this; var concatenatedId = this.getConcatenatedId(evt); this.store.set(concatenatedId, revInEvt + 1, revInStore, function (err) { if (er...
[ "function", "(", "evt", ",", "revInStore", ",", "callback", ")", "{", "var", "evtId", "=", "dotty", ".", "get", "(", "evt", ",", "this", ".", "definition", ".", "id", ")", ";", "var", "revInEvt", "=", "dotty", ".", "get", "(", "evt", ",", "this", ...
Finishes the guard stuff and save the new revision to store. @param {Object} evt The event object. @param {Number} revInStore The actual revision number in store. @param {Function} callback The function, that will be called when this action is completed. `function(err){}`
[ "Finishes", "the", "guard", "stuff", "and", "save", "the", "new", "revision", "to", "store", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/revisionGuard.js#L185-L231
train
adrai/node-cqrs-saga
lib/orderQueue.js
function (id, objId, object, clb, fn) { this.queue[id] = this.queue[id] || []; var alreadyInQueue = _.find(this.queue[id], function (o) { return o.id === objId; }); if (alreadyInQueue) { debug('event already handling [concatenatedId]=' + id + ', [evtId]=' + objId); clb(new AlreadyHan...
javascript
function (id, objId, object, clb, fn) { this.queue[id] = this.queue[id] || []; var alreadyInQueue = _.find(this.queue[id], function (o) { return o.id === objId; }); if (alreadyInQueue) { debug('event already handling [concatenatedId]=' + id + ', [evtId]=' + objId); clb(new AlreadyHan...
[ "function", "(", "id", ",", "objId", ",", "object", ",", "clb", ",", "fn", ")", "{", "this", ".", "queue", "[", "id", "]", "=", "this", ".", "queue", "[", "id", "]", "||", "[", "]", ";", "var", "alreadyInQueue", "=", "_", ".", "find", "(", "t...
Pushes a new item in the queue. @param {String} id The aggregate id. @param {String} objId The event id. @param {Object} object The event. @param {Function} clb The callback function for the event handle. @param {Function} fn The timeout function handle.
[ "Pushes", "a", "new", "item", "in", "the", "queue", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/orderQueue.js#L26-L62
train
adrai/node-cqrs-saga
lib/orderQueue.js
function (id, objId) { if (this.queue[id]) { _.remove(this.queue[id], function (o) { return o.id === objId; }); } if (objId && this.retries[id] && this.retries[id][objId]) { this.retries[id][objId] = 0; } }
javascript
function (id, objId) { if (this.queue[id]) { _.remove(this.queue[id], function (o) { return o.id === objId; }); } if (objId && this.retries[id] && this.retries[id][objId]) { this.retries[id][objId] = 0; } }
[ "function", "(", "id", ",", "objId", ")", "{", "if", "(", "this", ".", "queue", "[", "id", "]", ")", "{", "_", ".", "remove", "(", "this", ".", "queue", "[", "id", "]", ",", "function", "(", "o", ")", "{", "return", "o", ".", "id", "===", "...
Removes an event from the queue. @param {String} id The aggregate id. @param {String} objId The event id.
[ "Removes", "an", "event", "from", "the", "queue", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/orderQueue.js#L81-L91
train
adrai/node-cqrs-saga
lib/pm.js
function (fn) { if (!fn || !_.isFunction(fn)) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } this.onEventMissingHandle = fn; return this; }
javascript
function (fn) { if (!fn || !_.isFunction(fn)) { var err = new Error('Please pass a valid function!'); debug(err); throw err; } this.onEventMissingHandle = fn; return this; }
[ "function", "(", "fn", ")", "{", "if", "(", "!", "fn", "||", "!", "_", ".", "isFunction", "(", "fn", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid function!'", ")", ";", "debug", "(", "err", ")", ";", "throw", "err", ...
Inject function for event missing handle. @param {Function} fn the function to be injected @returns {ProcessManager} to be able to chain...
[ "Inject", "function", "for", "event", "missing", "handle", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L200-L210
train
adrai/node-cqrs-saga
lib/pm.js
function (callback) { var self = this; var warnings = null; async.series([ // load saga files... function (callback) { if (self.options.sagaPath === '') { self.sagas = {}; debug('empty sagaPath defined so no sagas will be loaded...'); return callback(null...
javascript
function (callback) { var self = this; var warnings = null; async.series([ // load saga files... function (callback) { if (self.options.sagaPath === '') { self.sagas = {}; debug('empty sagaPath defined so no sagas will be loaded...'); return callback(null...
[ "function", "(", "callback", ")", "{", "var", "self", "=", "this", ";", "var", "warnings", "=", "null", ";", "async", ".", "series", "(", "[", "// load saga files...", "function", "(", "callback", ")", "{", "if", "(", "self", ".", "options", ".", "saga...
Call this function to initialize the saga. @param {Function} callback the function that will be called when this action has finished [optional] `function(err){}`
[ "Call", "this", "function", "to", "initialize", "the", "saga", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L217-L314
train
adrai/node-cqrs-saga
lib/pm.js
function (callback) { if (self.options.sagaPath === '') { self.sagas = {}; debug('empty sagaPath defined so no sagas will be loaded...'); return callback(null); } debug('load saga files...'); self.structureLoader(self.options.sagaPath, function (err, sagas, ...
javascript
function (callback) { if (self.options.sagaPath === '') { self.sagas = {}; debug('empty sagaPath defined so no sagas will be loaded...'); return callback(null); } debug('load saga files...'); self.structureLoader(self.options.sagaPath, function (err, sagas, ...
[ "function", "(", "callback", ")", "{", "if", "(", "self", ".", "options", ".", "sagaPath", "===", "''", ")", "{", "self", ".", "sagas", "=", "{", "}", ";", "debug", "(", "'empty sagaPath defined so no sagas will be loaded...'", ")", ";", "return", "callback"...
load saga files...
[ "load", "saga", "files", "..." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L225-L240
train
adrai/node-cqrs-saga
lib/pm.js
function (callback) { debug('prepare sagaStore...'); self.sagaStore.on('connect', function () { self.emit('connect'); }); self.sagaStore.on('disconnect', function () { self.emit('disconnect'); }); self.sagaStore.conne...
javascript
function (callback) { debug('prepare sagaStore...'); self.sagaStore.on('connect', function () { self.emit('connect'); }); self.sagaStore.on('disconnect', function () { self.emit('disconnect'); }); self.sagaStore.conne...
[ "function", "(", "callback", ")", "{", "debug", "(", "'prepare sagaStore...'", ")", ";", "self", ".", "sagaStore", ".", "on", "(", "'connect'", ",", "function", "(", ")", "{", "self", ".", "emit", "(", "'connect'", ")", ";", "}", ")", ";", "self", "....
prepare sagaStore...
[ "prepare", "sagaStore", "..." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L248-L260
train
adrai/node-cqrs-saga
lib/pm.js
function (evt, callback) { var self = this; this.eventDispatcher.dispatch(evt, function (errs, sagaModels) { var cmds = []; if (!sagaModels || sagaModels.length === 0) { if (callback) { callback(errs, cmds, []); } return; } async.each(sagaModels, func...
javascript
function (evt, callback) { var self = this; this.eventDispatcher.dispatch(evt, function (errs, sagaModels) { var cmds = []; if (!sagaModels || sagaModels.length === 0) { if (callback) { callback(errs, cmds, []); } return; } async.each(sagaModels, func...
[ "function", "(", "evt", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "this", ".", "eventDispatcher", ".", "dispatch", "(", "evt", ",", "function", "(", "errs", ",", "sagaModels", ")", "{", "var", "cmds", "=", "[", "]", ";", "if", "("...
Call this function to forward it to the dispatcher. @param {Object} evt The event object @param {Function} callback The function that will be called when this action has finished [optional] `function(errs, evt, notifications){}` notifications is of type Array
[ "Call", "this", "function", "to", "forward", "it", "to", "the", "dispatcher", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L336-L403
train
adrai/node-cqrs-saga
lib/pm.js
function (evt, callback) { if (!evt || !_.isObject(evt)) { var err = new Error('Please pass a valid event!'); debug(err); throw err; } var self = this; var workWithRevisionGuard = false; if ( this.revisionGuard && !!this.definitions.event.revision && dotty.exists(evt,...
javascript
function (evt, callback) { if (!evt || !_.isObject(evt)) { var err = new Error('Please pass a valid event!'); debug(err); throw err; } var self = this; var workWithRevisionGuard = false; if ( this.revisionGuard && !!this.definitions.event.revision && dotty.exists(evt,...
[ "function", "(", "evt", ",", "callback", ")", "{", "if", "(", "!", "evt", "||", "!", "_", ".", "isObject", "(", "evt", ")", ")", "{", "var", "err", "=", "new", "Error", "(", "'Please pass a valid event!'", ")", ";", "debug", "(", "err", ")", ";", ...
Call this function to let the saga handle it. @param {Object} evt The event object @param {Function} callback The function that will be called when this action has finished [optional] `function(err, cmds, sagaModels){}` cmds and sagaModels are of type Array
[ "Call", "this", "function", "to", "let", "the", "saga", "handle", "it", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L411-L473
train
adrai/node-cqrs-saga
lib/pm.js
function (date, callback) { var self = this; this.sagaStore.getOlderSagas(date, function (err, sagas) { if (err) { debug(err); return callback(err); } var sagaModels = []; sagas.forEach(function (s) { var sagaModel = new SagaModel(s.id); sagaModel.set(s);...
javascript
function (date, callback) { var self = this; this.sagaStore.getOlderSagas(date, function (err, sagas) { if (err) { debug(err); return callback(err); } var sagaModels = []; sagas.forEach(function (s) { var sagaModel = new SagaModel(s.id); sagaModel.set(s);...
[ "function", "(", "date", ",", "callback", ")", "{", "var", "self", "=", "this", ";", "this", ".", "sagaStore", ".", "getOlderSagas", "(", "date", ",", "function", "(", "err", ",", "sagas", ")", "{", "if", "(", "err", ")", "{", "debug", "(", "err", ...
Use this function to get all sagas that are older then the passed date. @param {Date} date The date @param {Function} callback The function, that will be called when this action is completed. `function(err, sagas){}` saga is of type Array.
[ "Use", "this", "function", "to", "get", "all", "sagas", "that", "are", "older", "then", "the", "passed", "date", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L593-L630
train
adrai/node-cqrs-saga
lib/pm.js
function (options, callback) { if (!callback) { callback = options; options = {}; } this.sagaStore.getUndispatchedCommands(options, callback); }
javascript
function (options, callback) { if (!callback) { callback = options; options = {}; } this.sagaStore.getUndispatchedCommands(options, callback); }
[ "function", "(", "options", ",", "callback", ")", "{", "if", "(", "!", "callback", ")", "{", "callback", "=", "options", ";", "options", "=", "{", "}", ";", "}", "this", ".", "sagaStore", ".", "getUndispatchedCommands", "(", "options", ",", "callback", ...
Use this function to get all undispatched commands. @param {Function} callback The function, that will be called when this action is completed. `function(err, cmdsSagaMap){}` cmdsSagaMap is of type Array.
[ "Use", "this", "function", "to", "get", "all", "undispatched", "commands", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L637-L643
train
adrai/node-cqrs-saga
lib/pm.js
function (saga, callback) { var sagaId = saga.id || saga; this.sagaStore.remove(sagaId, callback); }
javascript
function (saga, callback) { var sagaId = saga.id || saga; this.sagaStore.remove(sagaId, callback); }
[ "function", "(", "saga", ",", "callback", ")", "{", "var", "sagaId", "=", "saga", ".", "id", "||", "saga", ";", "this", ".", "sagaStore", ".", "remove", "(", "sagaId", ",", "callback", ")", ";", "}" ]
Use this function to remove the matched saga. @param {String} saga The id of the saga or the saga itself @param {Function} callback The function, that will be called when this action is completed. [optional] `function(err){}`
[ "Use", "this", "function", "to", "remove", "the", "matched", "saga", "." ]
9770440df0e50b5a3897607a07e0252315b25edf
https://github.com/adrai/node-cqrs-saga/blob/9770440df0e50b5a3897607a07e0252315b25edf/lib/pm.js#L662-L665
train
apis-is/apis
endpoints/declension/index.js
getDeclensions
function getDeclensions(callback, providedParams) { const params = Object.assign({}, providedParams) request.get(params, (err, res, body) => { if (err || res.statusCode !== 200) { return res.status(500).json({ error: 'A request to dev.phpbin.ja.is resulted in a error', }) } let $ ...
javascript
function getDeclensions(callback, providedParams) { const params = Object.assign({}, providedParams) request.get(params, (err, res, body) => { if (err || res.statusCode !== 200) { return res.status(500).json({ error: 'A request to dev.phpbin.ja.is resulted in a error', }) } let $ ...
[ "function", "getDeclensions", "(", "callback", ",", "providedParams", ")", "{", "const", "params", "=", "Object", ".", "assign", "(", "{", "}", ",", "providedParams", ")", "request", ".", "get", "(", "params", ",", "(", "err", ",", "res", ",", "body", ...
return permutation of a given word
[ "return", "permutation", "of", "a", "given", "word" ]
96a23ab30d5b498a0805da06cf87e84d61422c27
https://github.com/apis-is/apis/blob/96a23ab30d5b498a0805da06cf87e84d61422c27/endpoints/declension/index.js#L14-L50
train
ibm-developer/generator-ibm-core-node-express
app/templates/idt.js
runIDT
function runIDT(args) { const cmd = 'bx dev ' + args.join(' '); console.log(chalk.blue('Running:'), cmd); cp.execSync(cmd, {stdio: 'inherit'}); }
javascript
function runIDT(args) { const cmd = 'bx dev ' + args.join(' '); console.log(chalk.blue('Running:'), cmd); cp.execSync(cmd, {stdio: 'inherit'}); }
[ "function", "runIDT", "(", "args", ")", "{", "const", "cmd", "=", "'bx dev '", "+", "args", ".", "join", "(", "' '", ")", ";", "console", ".", "log", "(", "chalk", ".", "blue", "(", "'Running:'", ")", ",", "cmd", ")", ";", "cp", ".", "execSync", ...
Run IDT with whatever args we were given.
[ "Run", "IDT", "with", "whatever", "args", "we", "were", "given", "." ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/idt.js#L55-L59
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
function(resource) { var resource = Docs.escapeResourceName(resource); if (resource == '') { $('.resource ul.endpoints').slideUp(); return; } $('li#resource_' + resource).removeClass('active'); var elem = $('li#resource_' + resource + ' ul.endpoints'); elem.slideUp(); }
javascript
function(resource) { var resource = Docs.escapeResourceName(resource); if (resource == '') { $('.resource ul.endpoints').slideUp(); return; } $('li#resource_' + resource).removeClass('active'); var elem = $('li#resource_' + resource + ' ul.endpoints'); elem.slideUp(); }
[ "function", "(", "resource", ")", "{", "var", "resource", "=", "Docs", ".", "escapeResourceName", "(", "resource", ")", ";", "if", "(", "resource", "==", "''", ")", "{", "$", "(", "'.resource ul.endpoints'", ")", ".", "slideUp", "(", ")", ";", "return", ...
Collapse resource and mark as explicitly closed
[ "Collapse", "resource", "and", "mark", "as", "explicitly", "closed" ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L949-L960
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
runSingle
function runSingle(task, domain) { try { task(); } catch (e) { if (isNodeJS) { // In node, uncaught exceptions are considered fatal errors. // Re-throw them synchronously to interrupt flushing! // Ensure continuation if the uncaug...
javascript
function runSingle(task, domain) { try { task(); } catch (e) { if (isNodeJS) { // In node, uncaught exceptions are considered fatal errors. // Re-throw them synchronously to interrupt flushing! // Ensure continuation if the uncaug...
[ "function", "runSingle", "(", "task", ",", "domain", ")", "{", "try", "{", "task", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "if", "(", "isNodeJS", ")", "{", "// In node, uncaught exceptions are considered fatal errors.", "// Re-throw them synchronously to ...
runs a single function in the async queue
[ "runs", "a", "single", "function", "in", "the", "async", "queue" ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L18279-L18313
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
captureLine
function captureLine() { if (!hasStacks) { return; } try { throw new Error(); } catch (e) { var lines = e.stack.split("\n"); var firstLine = lines[0].indexOf("@") > 0 ? lines[1] : lines[2]; var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine); ...
javascript
function captureLine() { if (!hasStacks) { return; } try { throw new Error(); } catch (e) { var lines = e.stack.split("\n"); var firstLine = lines[0].indexOf("@") > 0 ? lines[1] : lines[2]; var fileNameAndLineNumber = getFileNameAndLineNumber(firstLine); ...
[ "function", "captureLine", "(", ")", "{", "if", "(", "!", "hasStacks", ")", "{", "return", ";", "}", "try", "{", "throw", "new", "Error", "(", ")", ";", "}", "catch", "(", "e", ")", "{", "var", "lines", "=", "e", ".", "stack", ".", "split", "("...
discover own file name and line number range for filtering stack traces
[ "discover", "own", "file", "name", "and", "line", "number", "range", "for", "filtering", "stack", "traces" ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L18596-L18614
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
Q
function Q(value) { // If the object is already a Promise, return it directly. This enables // the resolve function to both be used to created references from objects, // but to tolerably coerce non-promises to promises. if (value instanceof Promise) { return value; } // assimilate the...
javascript
function Q(value) { // If the object is already a Promise, return it directly. This enables // the resolve function to both be used to created references from objects, // but to tolerably coerce non-promises to promises. if (value instanceof Promise) { return value; } // assimilate the...
[ "function", "Q", "(", "value", ")", "{", "// If the object is already a Promise, return it directly. This enables", "// the resolve function to both be used to created references from objects,", "// but to tolerably coerce non-promises to promises.", "if", "(", "value", "instanceof", "Pro...
end of shims beginning of real work Constructs a promise for an immediate reference, passes promises through, or coerces promises from different systems. @param value immediate reference or promise
[ "end", "of", "shims", "beginning", "of", "real", "work", "Constructs", "a", "promise", "for", "an", "immediate", "reference", "passes", "promises", "through", "or", "coerces", "promises", "from", "different", "systems", "." ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L18635-L18649
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
continuer
function continuer(verb, arg) { var result; // Until V8 3.19 / Chromium 29 is released, SpiderMonkey is the only // engine that has a deployed base of browsers that support generators. // However, SM's generators use the Python-inspired semantics of // outdat...
javascript
function continuer(verb, arg) { var result; // Until V8 3.19 / Chromium 29 is released, SpiderMonkey is the only // engine that has a deployed base of browsers that support generators. // However, SM's generators use the Python-inspired semantics of // outdat...
[ "function", "continuer", "(", "verb", ",", "arg", ")", "{", "var", "result", ";", "// Until V8 3.19 / Chromium 29 is released, SpiderMonkey is the only", "// engine that has a deployed base of browsers that support generators.", "// However, SM's generators use the Python-inspired semantic...
when verb is "send", arg is a value when verb is "throw", arg is an exception
[ "when", "verb", "is", "send", "arg", "is", "a", "value", "when", "verb", "is", "throw", "arg", "is", "an", "exception" ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L19408-L19445
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
function(data){ if (data === undefined) { data = ''; } var $msgbar = $('#message-bar'); $msgbar.removeClass('message-fail'); $msgbar.addClass('message-success'); $msgbar.text(data); if(window.SwaggerTranslator) { window.SwaggerTranslator.translate($msgbar); } }
javascript
function(data){ if (data === undefined) { data = ''; } var $msgbar = $('#message-bar'); $msgbar.removeClass('message-fail'); $msgbar.addClass('message-success'); $msgbar.text(data); if(window.SwaggerTranslator) { window.SwaggerTranslator.translate($msgbar); } }
[ "function", "(", "data", ")", "{", "if", "(", "data", "===", "undefined", ")", "{", "data", "=", "''", ";", "}", "var", "$msgbar", "=", "$", "(", "'#message-bar'", ")", ";", "$msgbar", ".", "removeClass", "(", "'message-fail'", ")", ";", "$msgbar", "...
Shows message on topbar of the ui
[ "Shows", "message", "on", "topbar", "of", "the", "ui" ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L21945-L21956
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
function(data) { var h, headerArray, headers, i, l, len, o; headers = {}; headerArray = data.getAllResponseHeaders().split('\r'); for (l = 0, len = headerArray.length; l < len; l++) { i = headerArray[l]; h = i.match(/^([^:]*?):(.*)$/); if (!h) { h = []; } h.shift();...
javascript
function(data) { var h, headerArray, headers, i, l, len, o; headers = {}; headerArray = data.getAllResponseHeaders().split('\r'); for (l = 0, len = headerArray.length; l < len; l++) { i = headerArray[l]; h = i.match(/^([^:]*?):(.*)$/); if (!h) { h = []; } h.shift();...
[ "function", "(", "data", ")", "{", "var", "h", ",", "headerArray", ",", "headers", ",", "i", ",", "l", ",", "len", ",", "o", ";", "headers", "=", "{", "}", ";", "headerArray", "=", "data", ".", "getAllResponseHeaders", "(", ")", ".", "split", "(", ...
wraps a jquery response as a shred response
[ "wraps", "a", "jquery", "response", "as", "a", "shred", "response" ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L23582-L23605
train
ibm-developer/generator-ibm-core-node-express
app/templates/public/swagger-ui/swagger-ui.js
function(response) { var prettyJson = JSON.stringify(response, null, '\t').replace(/\n/g, '<br>'); $('.response_body', $(this.el)).html(_.escape(prettyJson)); }
javascript
function(response) { var prettyJson = JSON.stringify(response, null, '\t').replace(/\n/g, '<br>'); $('.response_body', $(this.el)).html(_.escape(prettyJson)); }
[ "function", "(", "response", ")", "{", "var", "prettyJson", "=", "JSON", ".", "stringify", "(", "response", ",", "null", ",", "'\\t'", ")", ".", "replace", "(", "/", "\\n", "/", "g", ",", "'<br>'", ")", ";", "$", "(", "'.response_body'", ",", "$", ...
Show response from server
[ "Show", "response", "from", "server" ]
ae55bb3fafc949b7d786cd45a10e10d30d9457a6
https://github.com/ibm-developer/generator-ibm-core-node-express/blob/ae55bb3fafc949b7d786cd45a10e10d30d9457a6/app/templates/public/swagger-ui/swagger-ui.js#L23634-L23637
train
magalhas/backbone-react-component
examples/blog/public/components/blog.js
function (event) { var target = event.target; var key = target.getAttribute('name'); var nextState = {}; nextState[key] = target.value; this.setState(nextState); }
javascript
function (event) { var target = event.target; var key = target.getAttribute('name'); var nextState = {}; nextState[key] = target.value; this.setState(nextState); }
[ "function", "(", "event", ")", "{", "var", "target", "=", "event", ".", "target", ";", "var", "key", "=", "target", ".", "getAttribute", "(", "'name'", ")", ";", "var", "nextState", "=", "{", "}", ";", "nextState", "[", "key", "]", "=", "target", "...
Whenever an input changes, set it into this.state
[ "Whenever", "an", "input", "changes", "set", "it", "into", "this", ".", "state" ]
5525a9576912461936f48d97e533bde0b793b327
https://github.com/magalhas/backbone-react-component/blob/5525a9576912461936f48d97e533bde0b793b327/examples/blog/public/components/blog.js#L47-L53
train
magalhas/backbone-react-component
examples/blog/public/components/blog.js
function (event) { var id = event.target.parentNode.getAttribute('data-id'); // By getting collection through this.state you get an hash of the collection this.setState(_.findWhere(this.state.collection, {id: id})); }
javascript
function (event) { var id = event.target.parentNode.getAttribute('data-id'); // By getting collection through this.state you get an hash of the collection this.setState(_.findWhere(this.state.collection, {id: id})); }
[ "function", "(", "event", ")", "{", "var", "id", "=", "event", ".", "target", ".", "parentNode", ".", "getAttribute", "(", "'data-id'", ")", ";", "// By getting collection through this.state you get an hash of the collection", "this", ".", "setState", "(", "_", ".",...
Getting the id of the post that triggered the edit button and passing the respective model into this.state.
[ "Getting", "the", "id", "of", "the", "post", "that", "triggered", "the", "edit", "button", "and", "passing", "the", "respective", "model", "into", "this", ".", "state", "." ]
5525a9576912461936f48d97e533bde0b793b327
https://github.com/magalhas/backbone-react-component/blob/5525a9576912461936f48d97e533bde0b793b327/examples/blog/public/components/blog.js#L56-L60
train
magalhas/backbone-react-component
examples/blog/public/components/blog.js
function (event) { event.preventDefault(); var collection = this.getCollection(); var id = this.state.id; var model; if (id) { // Update existing model model = collection.get(id); model.save(this.state, {wait: true}); } else { // Create a new one ...
javascript
function (event) { event.preventDefault(); var collection = this.getCollection(); var id = this.state.id; var model; if (id) { // Update existing model model = collection.get(id); model.save(this.state, {wait: true}); } else { // Create a new one ...
[ "function", "(", "event", ")", "{", "event", ".", "preventDefault", "(", ")", ";", "var", "collection", "=", "this", ".", "getCollection", "(", ")", ";", "var", "id", "=", "this", ".", "state", ".", "id", ";", "var", "model", ";", "if", "(", "id", ...
Save the new or existing post to the services
[ "Save", "the", "new", "or", "existing", "post", "to", "the", "services" ]
5525a9576912461936f48d97e533bde0b793b327
https://github.com/magalhas/backbone-react-component/blob/5525a9576912461936f48d97e533bde0b793b327/examples/blog/public/components/blog.js#L70-L85
train
magalhas/backbone-react-component
examples/blog/public/components/blog.js
function () { return ( React.DOM.div(null, this.state.collection && this.state.collection.map(this.createPost), this.createForm() ) ); }
javascript
function () { return ( React.DOM.div(null, this.state.collection && this.state.collection.map(this.createPost), this.createForm() ) ); }
[ "function", "(", ")", "{", "return", "(", "React", ".", "DOM", ".", "div", "(", "null", ",", "this", ".", "state", ".", "collection", "&&", "this", ".", "state", ".", "collection", ".", "map", "(", "this", ".", "createPost", ")", ",", "this", ".", ...
Go go react
[ "Go", "go", "react" ]
5525a9576912461936f48d97e533bde0b793b327
https://github.com/magalhas/backbone-react-component/blob/5525a9576912461936f48d97e533bde0b793b327/examples/blog/public/components/blog.js#L87-L94
train
clay/amphora
lib/services/attachRoutes.js
validPath
function validPath(path, site) { let reservedRoute; if (path[0] !== '/') { log('warn', `Cannot attach route '${path}' for site ${site.slug}. Path must begin with a slash.`); return false; } reservedRoute = _.find(reservedRoutes, (route) => path.indexOf(route) === 1); if (reservedRoute) { log('w...
javascript
function validPath(path, site) { let reservedRoute; if (path[0] !== '/') { log('warn', `Cannot attach route '${path}' for site ${site.slug}. Path must begin with a slash.`); return false; } reservedRoute = _.find(reservedRoutes, (route) => path.indexOf(route) === 1); if (reservedRoute) { log('w...
[ "function", "validPath", "(", "path", ",", "site", ")", "{", "let", "reservedRoute", ";", "if", "(", "path", "[", "0", "]", "!==", "'/'", ")", "{", "log", "(", "'warn'", ",", "`", "${", "path", "}", "${", "site", ".", "slug", "}", "`", ")", ";"...
Checks for validity of a route to be attached @param {String} path @param {Object} site @returns {Boolean}
[ "Checks", "for", "validity", "of", "a", "route", "to", "be", "attached" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/attachRoutes.js#L16-L32
train
clay/amphora
lib/services/attachRoutes.js
normalizeRedirectPath
function normalizeRedirectPath(redirect, site) { return site.path && !redirect.includes(site.path) ? `${site.path}${redirect}` : redirect; }
javascript
function normalizeRedirectPath(redirect, site) { return site.path && !redirect.includes(site.path) ? `${site.path}${redirect}` : redirect; }
[ "function", "normalizeRedirectPath", "(", "redirect", ",", "site", ")", "{", "return", "site", ".", "path", "&&", "!", "redirect", ".", "includes", "(", "site", ".", "path", ")", "?", "`", "${", "site", ".", "path", "}", "${", "redirect", "}", "`", "...
Normalizes redirects path appending site's path to it on sub-sites' redirects. @param {String} redirect @param {Object} site @return {String}
[ "Normalizes", "redirects", "path", "appending", "site", "s", "path", "to", "it", "on", "sub", "-", "sites", "redirects", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/attachRoutes.js#L40-L42
train
clay/amphora
lib/services/attachRoutes.js
attachRedirect
function attachRedirect(router, { path, redirect }, site) { redirect = normalizeRedirectPath(redirect, site); return router.get(path, (req, res) => { res.redirect(301, redirect); }); }
javascript
function attachRedirect(router, { path, redirect }, site) { redirect = normalizeRedirectPath(redirect, site); return router.get(path, (req, res) => { res.redirect(301, redirect); }); }
[ "function", "attachRedirect", "(", "router", ",", "{", "path", ",", "redirect", "}", ",", "site", ")", "{", "redirect", "=", "normalizeRedirectPath", "(", "redirect", ",", "site", ")", ";", "return", "router", ".", "get", "(", "path", ",", "(", "req", ...
Attaches a route with redirect to the router. @param {Router} router @param {Object} route @param {String} route.path @param {String} route.redirect @param {Object} site @return {Router}
[ "Attaches", "a", "route", "with", "redirect", "to", "the", "router", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/attachRoutes.js#L64-L70
train
clay/amphora
lib/services/attachRoutes.js
attachDynamicRoute
function attachDynamicRoute(router, { path, dynamicPage }) { return router.get(path, render.renderDynamicRoute(dynamicPage)); }
javascript
function attachDynamicRoute(router, { path, dynamicPage }) { return router.get(path, render.renderDynamicRoute(dynamicPage)); }
[ "function", "attachDynamicRoute", "(", "router", ",", "{", "path", ",", "dynamicPage", "}", ")", "{", "return", "router", ".", "get", "(", "path", ",", "render", ".", "renderDynamicRoute", "(", "dynamicPage", ")", ")", ";", "}" ]
Attaches a dynamic route to the router. @param {Router} router @param {Object} route @param {String} route.path @param {String} route.dynamicPage @return {Router}
[ "Attaches", "a", "dynamic", "route", "to", "the", "router", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/attachRoutes.js#L80-L82
train
clay/amphora
lib/services/attachRoutes.js
parseHandler
function parseHandler(router, routeObj, site) { const { redirect, dynamicPage, path, middleware } = routeObj; if (!validPath(path, site)) { return; } if (middleware) { router.use(path, middleware); } if (redirect) { return attachRedirect(router, routeObj, site); } else if (dynamicPage) { ...
javascript
function parseHandler(router, routeObj, site) { const { redirect, dynamicPage, path, middleware } = routeObj; if (!validPath(path, site)) { return; } if (middleware) { router.use(path, middleware); } if (redirect) { return attachRedirect(router, routeObj, site); } else if (dynamicPage) { ...
[ "function", "parseHandler", "(", "router", ",", "routeObj", ",", "site", ")", "{", "const", "{", "redirect", ",", "dynamicPage", ",", "path", ",", "middleware", "}", "=", "routeObj", ";", "if", "(", "!", "validPath", "(", "path", ",", "site", ")", ")",...
Parses site route config object. @param {Router} router @param {Object} routeObj - Route config @param {Object} site @return {Router}
[ "Parses", "site", "route", "config", "object", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/attachRoutes.js#L91-L109
train
clay/amphora
lib/services/attachRoutes.js
attachRoutes
function attachRoutes(router, routes = [], site) { routes.forEach((route) => { parseHandler(router, route, site); }); return router; }
javascript
function attachRoutes(router, routes = [], site) { routes.forEach((route) => { parseHandler(router, route, site); }); return router; }
[ "function", "attachRoutes", "(", "router", ",", "routes", "=", "[", "]", ",", "site", ")", "{", "routes", ".", "forEach", "(", "(", "route", ")", "=>", "{", "parseHandler", "(", "router", ",", "route", ",", "site", ")", ";", "}", ")", ";", "return"...
Parses and attach all routes to the router. @param {Router} router @param {Object[]} routes @param {Object} site @param {Array} reservedRoutes @return {Router}
[ "Parses", "and", "attach", "all", "routes", "to", "the", "router", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/attachRoutes.js#L119-L125
train
clay/amphora
lib/services/composer.js
resolveComponentReferences
function resolveComponentReferences(data, locals, filter = referenceProperty) { const referenceObjects = references.listDeepObjects(data, filter); return bluebird.all(referenceObjects).each(referenceObject => { return components.get(referenceObject[referenceProperty], locals) .then(obj => { // th...
javascript
function resolveComponentReferences(data, locals, filter = referenceProperty) { const referenceObjects = references.listDeepObjects(data, filter); return bluebird.all(referenceObjects).each(referenceObject => { return components.get(referenceObject[referenceProperty], locals) .then(obj => { // th...
[ "function", "resolveComponentReferences", "(", "data", ",", "locals", ",", "filter", "=", "referenceProperty", ")", "{", "const", "referenceObjects", "=", "references", ".", "listDeepObjects", "(", "data", ",", "filter", ")", ";", "return", "bluebird", ".", "all...
Compose a component, recursively filling in all component references with instance data. @param {object} data @param {object} locals Extra data that some GETs use @param {function|string} [filter='_ref'] @returns {Promise} - Resolves with composed component data
[ "Compose", "a", "component", "recursively", "filling", "in", "all", "component", "references", "with", "instance", "data", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/composer.js#L19-L44
train
clay/amphora
lib/services/composer.js
composePage
function composePage(pageData, locals) { const layoutReference = pageData.layout, pageDataNoConf = references.omitPageConfiguration(pageData); return components.get(layoutReference) .then(layoutData => mapLayoutToPageData(pageDataNoConf, layoutData)) .then(fullData => resolveComponentReferences(fullDat...
javascript
function composePage(pageData, locals) { const layoutReference = pageData.layout, pageDataNoConf = references.omitPageConfiguration(pageData); return components.get(layoutReference) .then(layoutData => mapLayoutToPageData(pageDataNoConf, layoutData)) .then(fullData => resolveComponentReferences(fullDat...
[ "function", "composePage", "(", "pageData", ",", "locals", ")", "{", "const", "layoutReference", "=", "pageData", ".", "layout", ",", "pageDataNoConf", "=", "references", ".", "omitPageConfiguration", "(", "pageData", ")", ";", "return", "components", ".", "get"...
Compose a page, recursively filling in all component references with instance data. @param {object} pageData @param {object} locals @return {Promise} - Resolves with composed page data
[ "Compose", "a", "page", "recursively", "filling", "in", "all", "component", "references", "with", "instance", "data", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/composer.js#L53-L60
train
clay/amphora
lib/utils/layout-to-page-data.js
mapLayoutToPageData
function mapLayoutToPageData(pageData, layoutData) { // quickly (and shallowly) go through the layout's properties, // finding strings that map to page properties _.each(layoutData, function (list, key) { if (_.isString(list)) { if (_.isArray(pageData[key])) { // if you find a match and the data...
javascript
function mapLayoutToPageData(pageData, layoutData) { // quickly (and shallowly) go through the layout's properties, // finding strings that map to page properties _.each(layoutData, function (list, key) { if (_.isString(list)) { if (_.isArray(pageData[key])) { // if you find a match and the data...
[ "function", "mapLayoutToPageData", "(", "pageData", ",", "layoutData", ")", "{", "// quickly (and shallowly) go through the layout's properties,", "// finding strings that map to page properties", "_", ".", "each", "(", "layoutData", ",", "function", "(", "list", ",", "key", ...
Maps strings in arrays of layoutData into the properties of pageData @param {object} pageData @param {object} layoutData @returns {*}
[ "Maps", "strings", "in", "arrays", "of", "layoutData", "into", "the", "properties", "of", "pageData" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/utils/layout-to-page-data.js#L21-L39
train
clay/amphora
lib/services/uris.js
del
function del(uri, user, locals) { const callHooks = _.get(locals, 'hooks') !== 'false'; return db.get(uri).then(oldPageUri => { return db.del(uri).then(() => { const prefix = getPrefix(uri), site = siteService.getSiteFromPrefix(prefix), pageUrl = buf.decode(uri.split('/').pop()); i...
javascript
function del(uri, user, locals) { const callHooks = _.get(locals, 'hooks') !== 'false'; return db.get(uri).then(oldPageUri => { return db.del(uri).then(() => { const prefix = getPrefix(uri), site = siteService.getSiteFromPrefix(prefix), pageUrl = buf.decode(uri.split('/').pop()); i...
[ "function", "del", "(", "uri", ",", "user", ",", "locals", ")", "{", "const", "callHooks", "=", "_", ".", "get", "(", "locals", ",", "'hooks'", ")", "!==", "'false'", ";", "return", "db", ".", "get", "(", "uri", ")", ".", "then", "(", "oldPageUri",...
Deletes a URI NOTE: Return the data it used to contain. This is often used to create queues or messaging on the client-side, because clients can guarantee that only one client was allowed to be the last one to fetch a particular item. @param {string} uri @param {object} user @param {object} locals @returns {Promise}
[ "Deletes", "a", "URI" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/uris.js#L45-L64
train
clay/amphora
lib/services/upgrade.js
aggregateTransforms
function aggregateTransforms(schemaVersion, currentVersion, upgradeFile) { var transformVersions = generateVersionArray(upgradeFile), applicableVersions = []; for (let i = 0; i < transformVersions.length; i++) { let version = transformVersions[i]; if (!currentVersion && schemaVersion || schemaVersion ...
javascript
function aggregateTransforms(schemaVersion, currentVersion, upgradeFile) { var transformVersions = generateVersionArray(upgradeFile), applicableVersions = []; for (let i = 0; i < transformVersions.length; i++) { let version = transformVersions[i]; if (!currentVersion && schemaVersion || schemaVersion ...
[ "function", "aggregateTransforms", "(", "schemaVersion", ",", "currentVersion", ",", "upgradeFile", ")", "{", "var", "transformVersions", "=", "generateVersionArray", "(", "upgradeFile", ")", ",", "applicableVersions", "=", "[", "]", ";", "for", "(", "let", "i", ...
Iterate through the array of version transforms provided and determine which versions are valid to be run. - If the data has no current version but the schema declares one, then run it - If the current schema version is greater than the current version AND the tranform version is greater than the current version, run ...
[ "Iterate", "through", "the", "array", "of", "version", "transforms", "provided", "and", "determine", "which", "versions", "are", "valid", "to", "be", "run", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/upgrade.js#L56-L69
train
clay/amphora
lib/services/upgrade.js
runTransforms
function runTransforms(transforms, upgradeFile, ref, data, locals) { log('debug', `Running ${transforms.length} transforms`); return bluebird.reduce(transforms, function (acc, val) { var key = val.toString(); // Parsefloat strips decimals with `.0` leaving just the int, // let's add them back in if...
javascript
function runTransforms(transforms, upgradeFile, ref, data, locals) { log('debug', `Running ${transforms.length} transforms`); return bluebird.reduce(transforms, function (acc, val) { var key = val.toString(); // Parsefloat strips decimals with `.0` leaving just the int, // let's add them back in if...
[ "function", "runTransforms", "(", "transforms", ",", "upgradeFile", ",", "ref", ",", "data", ",", "locals", ")", "{", "log", "(", "'debug'", ",", "`", "${", "transforms", ".", "length", "}", "`", ")", ";", "return", "bluebird", ".", "reduce", "(", "tra...
We have a the transforms we need to perform, so let's reduce them into the final data object. @param {Array} transforms @param {Object} upgradeFile @param {String} ref @param {Object} data @param {Object} locals @return {Promise}
[ "We", "have", "a", "the", "transforms", "we", "need", "to", "perform", "so", "let", "s", "reduce", "them", "into", "the", "final", "data", "object", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/upgrade.js#L82-L107
train
clay/amphora
lib/services/upgrade.js
saveTransformedData
function saveTransformedData(uri) { return function (data) { return db.put(uri, JSON.stringify(data)) .then(function () { // If the Promise resolves it means we saved, // so let's return the data return data; }); }; }
javascript
function saveTransformedData(uri) { return function (data) { return db.put(uri, JSON.stringify(data)) .then(function () { // If the Promise resolves it means we saved, // so let's return the data return data; }); }; }
[ "function", "saveTransformedData", "(", "uri", ")", "{", "return", "function", "(", "data", ")", "{", "return", "db", ".", "put", "(", "uri", ",", "JSON", ".", "stringify", "(", "data", ")", ")", ".", "then", "(", "function", "(", ")", "{", "// If th...
The data that was upgraded needs to be saved so that we never need to upgrade again. Send it to the DB before returning that data. @param {String} uri @return {Function}
[ "The", "data", "that", "was", "upgraded", "needs", "to", "be", "saved", "so", "that", "we", "never", "need", "to", "upgrade", "again", ".", "Send", "it", "to", "the", "DB", "before", "returning", "that", "data", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/upgrade.js#L117-L126
train
clay/amphora
lib/services/upgrade.js
upgradeData
function upgradeData(schemaVersion, dataVersion, ref, data, locals) { const name = isComponent(ref) ? getComponentName(ref) : getLayoutName(ref), dir = isComponent(ref) ? files.getComponentPath(name) : files.getLayoutPath(name), // Get the component directory upgradeFile = files.tryRequire(path.resolve(dir, '...
javascript
function upgradeData(schemaVersion, dataVersion, ref, data, locals) { const name = isComponent(ref) ? getComponentName(ref) : getLayoutName(ref), dir = isComponent(ref) ? files.getComponentPath(name) : files.getLayoutPath(name), // Get the component directory upgradeFile = files.tryRequire(path.resolve(dir, '...
[ "function", "upgradeData", "(", "schemaVersion", ",", "dataVersion", ",", "ref", ",", "data", ",", "locals", ")", "{", "const", "name", "=", "isComponent", "(", "ref", ")", "?", "getComponentName", "(", "ref", ")", ":", "getLayoutName", "(", "ref", ")", ...
We know a upgrade needs to happen, so let's kick it off. If there is no upgrade file, return early cause we can't do anything. If it exists though, we need to find which transforms to perform, make them happen, save that new data and then send it back @param {Number} schemaVersion @param {Number} dataVersion @param...
[ "We", "know", "a", "upgrade", "needs", "to", "happen", "so", "let", "s", "kick", "it", "off", ".", "If", "there", "is", "no", "upgrade", "file", "return", "early", "cause", "we", "can", "t", "do", "anything", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/upgrade.js#L144-L178
train
clay/amphora
lib/services/upgrade.js
checkForUpgrade
function checkForUpgrade(ref, data, locals) { return utils.getSchema(ref) .then(schema => { // If version does not match what's in the data if (schema && schema._version && schema._version !== data._version) { return module.exports.upgradeData(schema._version, data._version, ref, data, locals)...
javascript
function checkForUpgrade(ref, data, locals) { return utils.getSchema(ref) .then(schema => { // If version does not match what's in the data if (schema && schema._version && schema._version !== data._version) { return module.exports.upgradeData(schema._version, data._version, ref, data, locals)...
[ "function", "checkForUpgrade", "(", "ref", ",", "data", ",", "locals", ")", "{", "return", "utils", ".", "getSchema", "(", "ref", ")", ".", "then", "(", "schema", "=>", "{", "// If version does not match what's in the data", "if", "(", "schema", "&&", "schema"...
Grab the schema for the component and check if the schema and data versions do not match. If they do we don't need to do anything, otherwise the upgrade process needs to be kicked off. @param {String} ref @param {Object} data @param {Object} locals @return {Promise}
[ "Grab", "the", "schema", "for", "the", "component", "and", "check", "if", "the", "schema", "and", "data", "versions", "do", "not", "match", ".", "If", "they", "do", "we", "don", "t", "need", "to", "do", "anything", "otherwise", "the", "upgrade", "process...
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/upgrade.js#L191-L201
train
clay/amphora
lib/services/db.js
defer
function defer() { const def = promiseDefer(); def.apply = function (err, result) { if (err) { def.reject(err); } else { def.resolve(result); } }; return def; }
javascript
function defer() { const def = promiseDefer(); def.apply = function (err, result) { if (err) { def.reject(err); } else { def.resolve(result); } }; return def; }
[ "function", "defer", "(", ")", "{", "const", "def", "=", "promiseDefer", "(", ")", ";", "def", ".", "apply", "=", "function", "(", "err", ",", "result", ")", "{", "if", "(", "err", ")", "{", "def", ".", "reject", "(", "err", ")", ";", "}", "els...
Use ES6 promises @returns {{apply: function}}
[ "Use", "ES6", "promises" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/db.js#L12-L24
train
clay/amphora
lib/services/db.js
list
function list(options = {}) { options = _.defaults(options, { limit: -1, keys: true, values: true, fillCache: false, json: true }); // The prefix option is a shortcut for a greaterThan and lessThan range. if (options.prefix) { // \x00 is the first possible alphanumeric character, and \x...
javascript
function list(options = {}) { options = _.defaults(options, { limit: -1, keys: true, values: true, fillCache: false, json: true }); // The prefix option is a shortcut for a greaterThan and lessThan range. if (options.prefix) { // \x00 is the first possible alphanumeric character, and \x...
[ "function", "list", "(", "options", "=", "{", "}", ")", "{", "options", "=", "_", ".", "defaults", "(", "options", ",", "{", "limit", ":", "-", "1", ",", "keys", ":", "true", ",", "values", ":", "true", ",", "fillCache", ":", "false", ",", "json"...
Get a read stream of all the keys. @example db.list({prefix: '/_components/hey'}) WARNING: Try to always end with the same character (like a /) or be completely consistent with your prefixing because the '/' character is right in the middle of the sorting range of characters. You will get weird results if you're no...
[ "Get", "a", "read", "stream", "of", "all", "the", "keys", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/db.js#L56-L101
train
clay/amphora
lib/services/publish.js
_checkForUrlProperty
function _checkForUrlProperty(uri, { url, customUrl }) { if (!url && !customUrl) { return bluebird.reject(new Error('Page does not have a `url` or `customUrl` property set')); } return bluebird.resolve(url || customUrl); }
javascript
function _checkForUrlProperty(uri, { url, customUrl }) { if (!url && !customUrl) { return bluebird.reject(new Error('Page does not have a `url` or `customUrl` property set')); } return bluebird.resolve(url || customUrl); }
[ "function", "_checkForUrlProperty", "(", "uri", ",", "{", "url", ",", "customUrl", "}", ")", "{", "if", "(", "!", "url", "&&", "!", "customUrl", ")", "{", "return", "bluebird", ".", "reject", "(", "new", "Error", "(", "'Page does not have a `url` or `customU...
Return the url for a page based on own url. This occurs when a page falls outside of all publishing rules supplied by the implementation BUT there is a `url` property already set on the page data. @param {String} uri @param {Object} pageData @param {String} pageData.url @param {String} pageData.customUrl @returns {Pro...
[ "Return", "the", "url", "for", "a", "page", "based", "on", "own", "url", ".", "This", "occurs", "when", "a", "page", "falls", "outside", "of", "all", "publishing", "rules", "supplied", "by", "the", "implementation", "BUT", "there", "is", "a", "url", "pro...
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/publish.js#L84-L90
train
clay/amphora
lib/services/publish.js
_checkForDynamicPage
function _checkForDynamicPage(uri, { _dynamic }) { if (!_dynamic || typeof _dynamic !== 'boolean') { return bluebird.reject(new Error('Page is not dynamic and requires a url')); } return bluebird.resolve(_dynamic); }
javascript
function _checkForDynamicPage(uri, { _dynamic }) { if (!_dynamic || typeof _dynamic !== 'boolean') { return bluebird.reject(new Error('Page is not dynamic and requires a url')); } return bluebird.resolve(_dynamic); }
[ "function", "_checkForDynamicPage", "(", "uri", ",", "{", "_dynamic", "}", ")", "{", "if", "(", "!", "_dynamic", "||", "typeof", "_dynamic", "!==", "'boolean'", ")", "{", "return", "bluebird", ".", "reject", "(", "new", "Error", "(", "'Page is not dynamic an...
Allow a page to be published if it is dynamic. This allows the page to be published, but the pages service has the logic to not create a _uri to point to the page @param {String} uri @param {Boolean|Undefined} _dynamic @return {Promise}
[ "Allow", "a", "page", "to", "be", "published", "if", "it", "is", "dynamic", ".", "This", "allows", "the", "page", "to", "be", "published", "but", "the", "pages", "service", "has", "the", "logic", "to", "not", "create", "a", "_uri", "to", "point", "to",...
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/publish.js#L101-L107
train
clay/amphora
lib/services/publish.js
_checkForArchived
function _checkForArchived(uri) { return db.getMeta(replaceVersion(uri)) .then(meta => meta.archived) .then(archived => archived ? bluebird.reject({ val: '', errors: { _checkForArchived: 'The page is archived and cannot be published' } }) : bluebird.resolve({ val: '', errors: {} }) ); }
javascript
function _checkForArchived(uri) { return db.getMeta(replaceVersion(uri)) .then(meta => meta.archived) .then(archived => archived ? bluebird.reject({ val: '', errors: { _checkForArchived: 'The page is archived and cannot be published' } }) : bluebird.resolve({ val: '', errors: {} }) ); }
[ "function", "_checkForArchived", "(", "uri", ")", "{", "return", "db", ".", "getMeta", "(", "replaceVersion", "(", "uri", ")", ")", ".", "then", "(", "meta", "=>", "meta", ".", "archived", ")", ".", "then", "(", "archived", "=>", "archived", "?", "blue...
Checks the archive property on a page's meta object, to determine whether it can be published. Archived pages should not be published. Otherwise, an initial object is passed to the processing chain in processPublishRules. @param {String} uri @returns {Promise}
[ "Checks", "the", "archive", "property", "on", "a", "page", "s", "meta", "object", "to", "determine", "whether", "it", "can", "be", "published", ".", "Archived", "pages", "should", "not", "be", "published", ".", "Otherwise", "an", "initial", "object", "is", ...
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/publish.js#L117-L124
train
clay/amphora
lib/services/publish.js
addToMeta
function addToMeta(meta, modifiers = [], uri, data) { if (!modifiers.length) return meta; return bluebird.reduce(modifiers, (acc, modify) => { return bluebird.try(modify.bind(null, uri, data, acc)) .then(resp => Object.assign(acc, resp)); }, {}).then(acc => Object.assign(acc, meta)); }
javascript
function addToMeta(meta, modifiers = [], uri, data) { if (!modifiers.length) return meta; return bluebird.reduce(modifiers, (acc, modify) => { return bluebird.try(modify.bind(null, uri, data, acc)) .then(resp => Object.assign(acc, resp)); }, {}).then(acc => Object.assign(acc, meta)); }
[ "function", "addToMeta", "(", "meta", ",", "modifiers", "=", "[", "]", ",", "uri", ",", "data", ")", "{", "if", "(", "!", "modifiers", ".", "length", ")", "return", "meta", ";", "return", "bluebird", ".", "reduce", "(", "modifiers", ",", "(", "acc", ...
Allow functions to add data to the meta object. Functions are defined on the site controller and can be synchronous or async. @param {Object} meta @param {Array} modifiers @param {String} uri @param {Object} data @returns {Promise}
[ "Allow", "functions", "to", "add", "data", "to", "the", "meta", "object", ".", "Functions", "are", "defined", "on", "the", "site", "controller", "and", "can", "be", "synchronous", "or", "async", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/publish.js#L137-L144
train
clay/amphora
lib/services/publish.js
publishPageAtUrl
function publishPageAtUrl(url, uri, data, locals, site) { // eslint-disable-line if (data._dynamic) { locals.isDynamicPublishUrl = true; return data; } // set the publishUrl for component's model.js files that // may want to know about the URL of the page locals.publishUrl = url; return bluebird.r...
javascript
function publishPageAtUrl(url, uri, data, locals, site) { // eslint-disable-line if (data._dynamic) { locals.isDynamicPublishUrl = true; return data; } // set the publishUrl for component's model.js files that // may want to know about the URL of the page locals.publishUrl = url; return bluebird.r...
[ "function", "publishPageAtUrl", "(", "url", ",", "uri", ",", "data", ",", "locals", ",", "site", ")", "{", "// eslint-disable-line", "if", "(", "data", ".", "_dynamic", ")", "{", "locals", ".", "isDynamicPublishUrl", "=", "true", ";", "return", "data", ";"...
Always do these actions when publishing a page @param {String} url @param {String} uri @param {Object} data @param {Object} locals @param {Object} site @return {Promise}
[ "Always", "do", "these", "actions", "when", "publishing", "a", "page" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/publish.js#L156-L170
train
clay/amphora
lib/services/publish.js
processPublishRules
function processPublishRules(publishingChain, uri, pageData, locals) { // check whether page is archived, then run the rest of the publishing chain return _checkForArchived(uri) .then(initialObj => { return bluebird.reduce(publishingChain, (acc, fn, index) => { if (!acc.val) { return bl...
javascript
function processPublishRules(publishingChain, uri, pageData, locals) { // check whether page is archived, then run the rest of the publishing chain return _checkForArchived(uri) .then(initialObj => { return bluebird.reduce(publishingChain, (acc, fn, index) => { if (!acc.val) { return bl...
[ "function", "processPublishRules", "(", "publishingChain", ",", "uri", ",", "pageData", ",", "locals", ")", "{", "// check whether page is archived, then run the rest of the publishing chain", "return", "_checkForArchived", "(", "uri", ")", ".", "then", "(", "initialObj", ...
Reduce through the publishing rules supplied by the site and aggregate the error messages until a valid url is retrieved. Once retrieved, skip the rest of the rules quickly and return the result. @param {Array} publishingChain @param {String} uri @param {Object} pageData @param {Object} locals @returns {Promise}
[ "Reduce", "through", "the", "publishing", "rules", "supplied", "by", "the", "site", "and", "aggregate", "the", "error", "messages", "until", "a", "valid", "url", "is", "retrieved", ".", "Once", "retrieved", "skip", "the", "rest", "of", "the", "rules", "quick...
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/publish.js#L185-L206
train
clay/amphora
lib/services/publish.js
validatePublishRules
function validatePublishRules(uri, { val, errors }) { let err, errMsg; if (!val) { errMsg = `Error publishing page: ${replaceVersion(uri)}`; log('error', errMsg, { publishRuleErrors: errors }); err = new Error(errMsg); err.status = 400; return bluebird.reject(err); } return val; }
javascript
function validatePublishRules(uri, { val, errors }) { let err, errMsg; if (!val) { errMsg = `Error publishing page: ${replaceVersion(uri)}`; log('error', errMsg, { publishRuleErrors: errors }); err = new Error(errMsg); err.status = 400; return bluebird.reject(err); } return val; }
[ "function", "validatePublishRules", "(", "uri", ",", "{", "val", ",", "errors", "}", ")", "{", "let", "err", ",", "errMsg", ";", "if", "(", "!", "val", ")", "{", "errMsg", "=", "`", "${", "replaceVersion", "(", "uri", ")", "}", "`", ";", "log", "...
Given the response from the processing of the publish rules, determine if we need to log errors or if we're good to proceed. @param {String} uri @param {String} val @param {Object} errors @returns {String|Promise<Error>}
[ "Given", "the", "response", "from", "the", "processing", "of", "the", "publish", "rules", "determine", "if", "we", "need", "to", "log", "errors", "or", "if", "we", "re", "good", "to", "proceed", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/publish.js#L218-L230
train
clay/amphora
lib/responses.js
removePrefix
function removePrefix(str, prefixToken) { const index = str.indexOf(prefixToken); if (index > -1) { str = str.substr(index + prefixToken.length).trim(); } return str; }
javascript
function removePrefix(str, prefixToken) { const index = str.indexOf(prefixToken); if (index > -1) { str = str.substr(index + prefixToken.length).trim(); } return str; }
[ "function", "removePrefix", "(", "str", ",", "prefixToken", ")", "{", "const", "index", "=", "str", ".", "indexOf", "(", "prefixToken", ")", ";", "if", "(", "index", ">", "-", "1", ")", "{", "str", "=", "str", ".", "substr", "(", "index", "+", "pre...
Finds prefixToken, and removes it and anything before it. @param {string} str @param {string} prefixToken @returns {string}
[ "Finds", "prefixToken", "and", "removes", "it", "and", "anything", "before", "it", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L19-L26
train
clay/amphora
lib/responses.js
notFound
function notFound(err, res) { if (!(err instanceof Error) && err) { res = err; } const message = 'Not Found', code = 404; // hide error from user of api. sendDefaultResponseForCode(code, message, res); }
javascript
function notFound(err, res) { if (!(err instanceof Error) && err) { res = err; } const message = 'Not Found', code = 404; // hide error from user of api. sendDefaultResponseForCode(code, message, res); }
[ "function", "notFound", "(", "err", ",", "res", ")", "{", "if", "(", "!", "(", "err", "instanceof", "Error", ")", "&&", "err", ")", "{", "res", "=", "err", ";", "}", "const", "message", "=", "'Not Found'", ",", "code", "=", "404", ";", "// hide err...
All "Not Found" errors are routed like this. @param {Error} [err] @param {object} res
[ "All", "Not", "Found", "errors", "are", "routed", "like", "this", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L266-L276
train
clay/amphora
lib/responses.js
serverError
function serverError(err, res) { // error is required to be logged log('error', err.message, { stack: err.stack }); const message = err.message || 'Server Error', // completely hide these messages from outside code = 500; sendDefaultResponseForCode(code, message, res); }
javascript
function serverError(err, res) { // error is required to be logged log('error', err.message, { stack: err.stack }); const message = err.message || 'Server Error', // completely hide these messages from outside code = 500; sendDefaultResponseForCode(code, message, res); }
[ "function", "serverError", "(", "err", ",", "res", ")", "{", "// error is required to be logged", "log", "(", "'error'", ",", "err", ".", "message", ",", "{", "stack", ":", "err", ".", "stack", "}", ")", ";", "const", "message", "=", "err", ".", "message...
All server errors should look like this. In general, 500s represent a _developer mistake_. We should try to replace them with more descriptive errors. @param {Error} err @param {object} res
[ "All", "server", "errors", "should", "look", "like", "this", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L285-L293
train
clay/amphora
lib/responses.js
expectText
function expectText(fn, res) { bluebird.try(fn).then(result => { res.set('Content-Type', 'text/plain'); res.send(result); }).catch(handleError(res)); }
javascript
function expectText(fn, res) { bluebird.try(fn).then(result => { res.set('Content-Type', 'text/plain'); res.send(result); }).catch(handleError(res)); }
[ "function", "expectText", "(", "fn", ",", "res", ")", "{", "bluebird", ".", "try", "(", "fn", ")", ".", "then", "(", "result", "=>", "{", "res", ".", "set", "(", "'Content-Type'", ",", "'text/plain'", ")", ";", "res", ".", "send", "(", "result", ")...
Reusable code to return Text data, both for good results AND errors. Captures and hides appropriate errors. @param {function} fn @param {object} res
[ "Reusable", "code", "to", "return", "Text", "data", "both", "for", "good", "results", "AND", "errors", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L368-L373
train
clay/amphora
lib/responses.js
checkArchivedToPublish
function checkArchivedToPublish(req, res, next) { if (req.body.archived) { return metaController.checkProps(req.uri, 'published') .then(resp => { if (resp === true) { throw new Error('Client error, cannot modify archive while page is published'); // archived true, published true } ...
javascript
function checkArchivedToPublish(req, res, next) { if (req.body.archived) { return metaController.checkProps(req.uri, 'published') .then(resp => { if (resp === true) { throw new Error('Client error, cannot modify archive while page is published'); // archived true, published true } ...
[ "function", "checkArchivedToPublish", "(", "req", ",", "res", ",", "next", ")", "{", "if", "(", "req", ".", "body", ".", "archived", ")", "{", "return", "metaController", ".", "checkProps", "(", "req", ".", "uri", ",", "'published'", ")", ".", "then", ...
Checks the archived property on the request object to determine if the request is attempting to archive the page. If true, checks the published property on the meta object of the page, by calling checkProps. @param {object} req @param {object} res @param {function} next @returns {Promise | void}
[ "Checks", "the", "archived", "property", "on", "the", "request", "object", "to", "determine", "if", "the", "request", "is", "attempting", "to", "archive", "the", "page", ".", "If", "true", "checks", "the", "published", "property", "on", "the", "meta", "objec...
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L384-L394
train
clay/amphora
lib/responses.js
expectJSON
function expectJSON(fn, res) { bluebird.try(fn).then(function (result) { res.json(result); }).catch(handleError(res)); }
javascript
function expectJSON(fn, res) { bluebird.try(fn).then(function (result) { res.json(result); }).catch(handleError(res)); }
[ "function", "expectJSON", "(", "fn", ",", "res", ")", "{", "bluebird", ".", "try", "(", "fn", ")", ".", "then", "(", "function", "(", "result", ")", "{", "res", ".", "json", "(", "result", ")", ";", "}", ")", ".", "catch", "(", "handleError", "("...
Reusable code to return JSON data, both for good results AND errors. Captures and hides appropriate errors. These return JSON always, because these endpoints are JSON-only. @param {function} fn @param {object} res
[ "Reusable", "code", "to", "return", "JSON", "data", "both", "for", "good", "results", "AND", "errors", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L405-L409
train
clay/amphora
lib/responses.js
list
function list(options) { return function (req, res) { let list, listOptions = _.assign({ prefix: req.uri, values: false }, options); list = db.list(listOptions); res.set('Content-Type', 'application/json'); list.pipe(res); }; }
javascript
function list(options) { return function (req, res) { let list, listOptions = _.assign({ prefix: req.uri, values: false }, options); list = db.list(listOptions); res.set('Content-Type', 'application/json'); list.pipe(res); }; }
[ "function", "list", "(", "options", ")", "{", "return", "function", "(", "req", ",", "res", ")", "{", "let", "list", ",", "listOptions", "=", "_", ".", "assign", "(", "{", "prefix", ":", "req", ".", "uri", ",", "values", ":", "false", "}", ",", "...
List all things in the db @param {object} [options] @param {string} [options.prefix] @param {boolean} [options.values] @param {function|array} [options.transforms] @returns {function}
[ "List", "all", "things", "in", "the", "db" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L419-L432
train
clay/amphora
lib/responses.js
listWithoutVersions
function listWithoutVersions() { const options = { transforms() { return [filter({wantStrings: true}, function (str) { return str.indexOf('@') === -1; })]; } }; return list(options); }
javascript
function listWithoutVersions() { const options = { transforms() { return [filter({wantStrings: true}, function (str) { return str.indexOf('@') === -1; })]; } }; return list(options); }
[ "function", "listWithoutVersions", "(", ")", "{", "const", "options", "=", "{", "transforms", "(", ")", "{", "return", "[", "filter", "(", "{", "wantStrings", ":", "true", "}", ",", "function", "(", "str", ")", "{", "return", "str", ".", "indexOf", "("...
List all things in the db that start with this prefix @returns {function}
[ "List", "all", "things", "in", "the", "db", "that", "start", "with", "this", "prefix" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L438-L448
train
clay/amphora
lib/responses.js
listWithPublishedVersions
function listWithPublishedVersions(req, res) { const publishedString = '@published', options = { transforms() { return [filter({ wantStrings: true }, function (str) { return str.indexOf(publishedString) !== -1; })]; } }; // Trim the URI to `../pages` for the query to w...
javascript
function listWithPublishedVersions(req, res) { const publishedString = '@published', options = { transforms() { return [filter({ wantStrings: true }, function (str) { return str.indexOf(publishedString) !== -1; })]; } }; // Trim the URI to `../pages` for the query to w...
[ "function", "listWithPublishedVersions", "(", "req", ",", "res", ")", "{", "const", "publishedString", "=", "'@published'", ",", "options", "=", "{", "transforms", "(", ")", "{", "return", "[", "filter", "(", "{", "wantStrings", ":", "true", "}", ",", "fun...
List all things in the db that start with this prefix _and_ are published @param {Object} req @param {Object} res @returns {Function}
[ "List", "all", "things", "in", "the", "db", "that", "start", "with", "this", "prefix", "_and_", "are", "published" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L458-L471
train
clay/amphora
lib/responses.js
putRouteFromDB
function putRouteFromDB(req, res) { expectJSON(function () { return db.put(req.uri, JSON.stringify(req.body)).then(() => req.body); }, res); }
javascript
function putRouteFromDB(req, res) { expectJSON(function () { return db.put(req.uri, JSON.stringify(req.body)).then(() => req.body); }, res); }
[ "function", "putRouteFromDB", "(", "req", ",", "res", ")", "{", "expectJSON", "(", "function", "(", ")", "{", "return", "db", ".", "put", "(", "req", ".", "uri", ",", "JSON", ".", "stringify", "(", "req", ".", "body", ")", ")", ".", "then", "(", ...
This route puts straight to the db. Assumptions: - that there is no extension if they're putting data. @param {object} req @param {object} res
[ "This", "route", "puts", "straight", "to", "the", "db", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L490-L494
train
clay/amphora
lib/responses.js
deleteRouteFromDB
function deleteRouteFromDB(req, res) { expectJSON(() => { return db.get(req.uri) .then(oldData => db.del(req.uri).then(() => oldData)); }, res); }
javascript
function deleteRouteFromDB(req, res) { expectJSON(() => { return db.get(req.uri) .then(oldData => db.del(req.uri).then(() => oldData)); }, res); }
[ "function", "deleteRouteFromDB", "(", "req", ",", "res", ")", "{", "expectJSON", "(", "(", ")", "=>", "{", "return", "db", ".", "get", "(", "req", ".", "uri", ")", ".", "then", "(", "oldData", "=>", "db", ".", "del", "(", "req", ".", "uri", ")", ...
This route deletes from the db, and returns what used to be there. Assumptions: - that there is no extension if they're deleting data. NOTE: Return the data it used to contain. This is often used to create queues or messaging on the client-side, because clients can guarantee that only one client was allowed to be th...
[ "This", "route", "deletes", "from", "the", "db", "and", "returns", "what", "used", "to", "be", "there", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L508-L513
train
clay/amphora
lib/responses.js
forceEditableInstance
function forceEditableInstance(code = 303) { return (req, res) => { res.redirect(code, `${res.locals.site.protocol}://${req.uri.replace('@published', '')}`); }; }
javascript
function forceEditableInstance(code = 303) { return (req, res) => { res.redirect(code, `${res.locals.site.protocol}://${req.uri.replace('@published', '')}`); }; }
[ "function", "forceEditableInstance", "(", "code", "=", "303", ")", "{", "return", "(", "req", ",", "res", ")", "=>", "{", "res", ".", "redirect", "(", "code", ",", "`", "${", "res", ".", "locals", ".", "site", ".", "protocol", "}", "${", "req", "."...
Forces a redirect back to the non-published version of a uri @param {Number} code @returns {Function}
[ "Forces", "a", "redirect", "back", "to", "the", "non", "-", "published", "version", "of", "a", "uri" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/responses.js#L522-L526
train
clay/amphora
lib/services/sites.js
normalizePath
function normalizePath(urlPath) { if (!urlPath) { return ''; // make sure path starts with a / } else if (_.head(urlPath) !== '/') { urlPath = '/' + urlPath; } // make sure path does not end with a / return _.trimEnd(urlPath, '/'); }
javascript
function normalizePath(urlPath) { if (!urlPath) { return ''; // make sure path starts with a / } else if (_.head(urlPath) !== '/') { urlPath = '/' + urlPath; } // make sure path does not end with a / return _.trimEnd(urlPath, '/'); }
[ "function", "normalizePath", "(", "urlPath", ")", "{", "if", "(", "!", "urlPath", ")", "{", "return", "''", ";", "// make sure path starts with a /", "}", "else", "if", "(", "_", ".", "head", "(", "urlPath", ")", "!==", "'/'", ")", "{", "urlPath", "=", ...
Normalize path to never end with a slash. @param {string} urlPath @returns {string}
[ "Normalize", "path", "to", "never", "end", "with", "a", "slash", "." ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/sites.js#L16-L25
train
clay/amphora
lib/services/sites.js
normalizeDirectory
function normalizeDirectory(dir) { if (!dir || dir === path.sep) { dir = '.'; } else if (_.head(dir) === path.sep) { dir = dir.substr(1); } if (dir.length > 1 && _.last(dir) === path.sep) { dir = dir.substring(0, dir.length - 1); } return dir; }
javascript
function normalizeDirectory(dir) { if (!dir || dir === path.sep) { dir = '.'; } else if (_.head(dir) === path.sep) { dir = dir.substr(1); } if (dir.length > 1 && _.last(dir) === path.sep) { dir = dir.substring(0, dir.length - 1); } return dir; }
[ "function", "normalizeDirectory", "(", "dir", ")", "{", "if", "(", "!", "dir", "||", "dir", "===", "path", ".", "sep", ")", "{", "dir", "=", "'.'", ";", "}", "else", "if", "(", "_", ".", "head", "(", "dir", ")", "===", "path", ".", "sep", ")", ...
Normalize directory to never start with slash, never end with slash, and always exist @param {string} dir @returns {string}
[ "Normalize", "directory", "to", "never", "start", "with", "slash", "never", "end", "with", "slash", "and", "always", "exist" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/sites.js#L32-L44
train
clay/amphora
lib/services/sites.js
getSite
function getSite(host, path) { // note: uses the memoized version return _.find(module.exports.sites(), function (site) { return site.host === host && site.path === path; }); }
javascript
function getSite(host, path) { // note: uses the memoized version return _.find(module.exports.sites(), function (site) { return site.host === host && site.path === path; }); }
[ "function", "getSite", "(", "host", ",", "path", ")", "{", "// note: uses the memoized version", "return", "_", ".", "find", "(", "module", ".", "exports", ".", "sites", "(", ")", ",", "function", "(", "site", ")", "{", "return", "site", ".", "host", "==...
get site config that matches a specific host + path @param {string} host @param {string} path (make sure it starts with a slash!) @returns {object}
[ "get", "site", "config", "that", "matches", "a", "specific", "host", "+", "path" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/sites.js#L100-L105
train
clay/amphora
lib/services/sites.js
getSiteFromPrefix
function getSiteFromPrefix(prefix) { var split = prefix.split('/'), // Split the url/uri by `/` host = split.shift(), // The first value should be the host ('http://' is not included) optPath = split.shift(), // The next value is the first part of the site's path OR the whole part path = optPath ?...
javascript
function getSiteFromPrefix(prefix) { var split = prefix.split('/'), // Split the url/uri by `/` host = split.shift(), // The first value should be the host ('http://' is not included) optPath = split.shift(), // The next value is the first part of the site's path OR the whole part path = optPath ?...
[ "function", "getSiteFromPrefix", "(", "prefix", ")", "{", "var", "split", "=", "prefix", ".", "split", "(", "'/'", ")", ",", "// Split the url/uri by `/`", "host", "=", "split", ".", "shift", "(", ")", ",", "// The first value should be the host ('http://' is not in...
Get the site a URI belongs to @param {string} prefix @returns {object}
[ "Get", "the", "site", "a", "URI", "belongs", "to" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/sites.js#L113-L132
train
clay/amphora
lib/services/metadata.js
userOrRobot
function userOrRobot(user) { if (user && _.get(user, 'username') && _.get(user, 'provider')) { return user; } else { // no actual user, this was an api key return { username: 'robot', provider: 'clay', imageUrl: 'clay-avatar', // kiln will supply a clay avatar name: 'Clay', ...
javascript
function userOrRobot(user) { if (user && _.get(user, 'username') && _.get(user, 'provider')) { return user; } else { // no actual user, this was an api key return { username: 'robot', provider: 'clay', imageUrl: 'clay-avatar', // kiln will supply a clay avatar name: 'Clay', ...
[ "function", "userOrRobot", "(", "user", ")", "{", "if", "(", "user", "&&", "_", ".", "get", "(", "user", ",", "'username'", ")", "&&", "_", ".", "get", "(", "user", ",", "'provider'", ")", ")", "{", "return", "user", ";", "}", "else", "{", "// no...
Either return the user object or the system for a specific action @param {Object} user @returns {Object}
[ "Either", "return", "the", "user", "object", "or", "the", "system", "for", "a", "specific", "action" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/metadata.js#L16-L29
train
clay/amphora
lib/services/metadata.js
publishPage
function publishPage(uri, publishMeta, user) { const NOW = new Date().toISOString(), update = { published: true, publishTime: NOW, history: [{ action: 'publish', timestamp: NOW, users: [userOrRobot(user)] }] }; return changeMetaState(uri, Object.assign(publishMeta, update)); }
javascript
function publishPage(uri, publishMeta, user) { const NOW = new Date().toISOString(), update = { published: true, publishTime: NOW, history: [{ action: 'publish', timestamp: NOW, users: [userOrRobot(user)] }] }; return changeMetaState(uri, Object.assign(publishMeta, update)); }
[ "function", "publishPage", "(", "uri", ",", "publishMeta", ",", "user", ")", "{", "const", "NOW", "=", "new", "Date", "(", ")", ".", "toISOString", "(", ")", ",", "update", "=", "{", "published", ":", "true", ",", "publishTime", ":", "NOW", ",", "his...
On publish of a page, update the metadara for the page @param {String} uri @param {Object} publishMeta @param {Object|Undefined} user @returns {Promise}
[ "On", "publish", "of", "a", "page", "update", "the", "metadara", "for", "the", "page" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/metadata.js#L40-L49
train
clay/amphora
lib/services/metadata.js
createPage
function createPage(ref, user) { const NOW = new Date().toISOString(), users = [userOrRobot(user)], meta = { createdAt: NOW, archived: false, published: false, publishTime: null, updateTime: null, urlHistory: [], firstPublishTime: null, url: '', title: '',...
javascript
function createPage(ref, user) { const NOW = new Date().toISOString(), users = [userOrRobot(user)], meta = { createdAt: NOW, archived: false, published: false, publishTime: null, updateTime: null, urlHistory: [], firstPublishTime: null, url: '', title: '',...
[ "function", "createPage", "(", "ref", ",", "user", ")", "{", "const", "NOW", "=", "new", "Date", "(", ")", ".", "toISOString", "(", ")", ",", "users", "=", "[", "userOrRobot", "(", "user", ")", "]", ",", "meta", "=", "{", "createdAt", ":", "NOW", ...
Create the initial meta object for the page @param {String} ref @param {Object|Underfined} user @returns {Promise}
[ "Create", "the", "initial", "meta", "object", "for", "the", "page" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/metadata.js#L59-L79
train
clay/amphora
lib/services/metadata.js
publishLayout
function publishLayout(uri, user) { const NOW = new Date().toISOString(), users = [userOrRobot(user)], update = { published: true, publishTime: NOW, history: [{ action: 'publish', timestamp: NOW, users }] }; return changeMetaState(uri, update); }
javascript
function publishLayout(uri, user) { const NOW = new Date().toISOString(), users = [userOrRobot(user)], update = { published: true, publishTime: NOW, history: [{ action: 'publish', timestamp: NOW, users }] }; return changeMetaState(uri, update); }
[ "function", "publishLayout", "(", "uri", ",", "user", ")", "{", "const", "NOW", "=", "new", "Date", "(", ")", ".", "toISOString", "(", ")", ",", "users", "=", "[", "userOrRobot", "(", "user", ")", "]", ",", "update", "=", "{", "published", ":", "tr...
Update the layouts meta object on publish @param {String} uri @param {Object} user @returns {Promise}
[ "Update", "the", "layouts", "meta", "object", "on", "publish" ]
b883a94cbc38c1891ce568addb6cb280aa1d5353
https://github.com/clay/amphora/blob/b883a94cbc38c1891ce568addb6cb280aa1d5353/lib/services/metadata.js#L106-L116
train