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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
emmetio/atom-plugin | lib/autocomplete/abbreviation.js | getSnippetsCompletions | function getSnippetsCompletions(editor, prefix) {
const syntax = detectSyntax(editor);
if (isStylesheet(syntax)) {
return getStylesheetSnippetsCompletions(editor, prefix);
} else if (syntax) {
return getMarkupSnippetsCompletions(editor, prefix);
}
return [];
} | javascript | function getSnippetsCompletions(editor, prefix) {
const syntax = detectSyntax(editor);
if (isStylesheet(syntax)) {
return getStylesheetSnippetsCompletions(editor, prefix);
} else if (syntax) {
return getMarkupSnippetsCompletions(editor, prefix);
}
return [];
} | [
"function",
"getSnippetsCompletions",
"(",
"editor",
",",
"prefix",
")",
"{",
"const",
"syntax",
"=",
"detectSyntax",
"(",
"editor",
")",
";",
"if",
"(",
"isStylesheet",
"(",
"syntax",
")",
")",
"{",
"return",
"getStylesheetSnippetsCompletions",
"(",
"editor",
... | Returns snippets completions for given editor.
@param {TextEditor} editor
@param {String} prefix
@return {String[]} | [
"Returns",
"snippets",
"completions",
"for",
"given",
"editor",
"."
] | a7b4a447647e493d1edf9df3fb901740c9fbc384 | https://github.com/emmetio/atom-plugin/blob/a7b4a447647e493d1edf9df3fb901740c9fbc384/lib/autocomplete/abbreviation.js#L137-L146 | train |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function() {
this.$el.addClass('timeline-me-container');
if(this.settings.orientation == 'horizontal') {
this.$el.addClass('timeline-me-horizontal');
if(this.settings.scrollBar == false)
this.$el.addClass('no-x-scroll');
} else {
... | javascript | function() {
this.$el.addClass('timeline-me-container');
if(this.settings.orientation == 'horizontal') {
this.$el.addClass('timeline-me-horizontal');
if(this.settings.scrollBar == false)
this.$el.addClass('no-x-scroll');
} else {
... | [
"function",
"(",
")",
"{",
"this",
".",
"$el",
".",
"addClass",
"(",
"'timeline-me-container'",
")",
";",
"if",
"(",
"this",
".",
"settings",
".",
"orientation",
"==",
"'horizontal'",
")",
"{",
"this",
".",
"$el",
".",
"addClass",
"(",
"'timeline-me-horizo... | Initialize the plugin instance.
Set any other attribtes, store any other element reference, register
listeners, etc
When bind listerners remember to name tag it with your plugin's name.
Elements can have more than one listener attached to the same event
so you need to tag it to unbind the appropriate listener on destr... | [
"Initialize",
"the",
"plugin",
"instance",
".",
"Set",
"any",
"other",
"attribtes",
"store",
"any",
"other",
"element",
"reference",
"register",
"listeners",
"etc"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L57-L132 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(items) {
var hasRelativePositioning = hasNumberProperty(items, 'relativePosition');
if(hasRelativePositioning) {
items.sort(function(a, b) {
return a.relativePosition - b.relativePosition;
});
}
} | javascript | function(items) {
var hasRelativePositioning = hasNumberProperty(items, 'relativePosition');
if(hasRelativePositioning) {
items.sort(function(a, b) {
return a.relativePosition - b.relativePosition;
});
}
} | [
"function",
"(",
"items",
")",
"{",
"var",
"hasRelativePositioning",
"=",
"hasNumberProperty",
"(",
"items",
",",
"'relativePosition'",
")",
";",
"if",
"(",
"hasRelativePositioning",
")",
"{",
"items",
".",
"sort",
"(",
"function",
"(",
"a",
",",
"b",
")",
... | Method that sort items, depending on their relativePosition | [
"Method",
"that",
"sort",
"items",
"depending",
"on",
"their",
"relativePosition"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L261-L269 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(items) {
var hasRelativePositioning = hasNumberProperty(items, 'relativePosition');
for(var i = 0; i < items.length; i++) {
if(i == items.length - 1)
items[i].diffWithNextRelativePos = undefined;
else
items[i].diff... | javascript | function(items) {
var hasRelativePositioning = hasNumberProperty(items, 'relativePosition');
for(var i = 0; i < items.length; i++) {
if(i == items.length - 1)
items[i].diffWithNextRelativePos = undefined;
else
items[i].diff... | [
"function",
"(",
"items",
")",
"{",
"var",
"hasRelativePositioning",
"=",
"hasNumberProperty",
"(",
"items",
",",
"'relativePosition'",
")",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
... | Method that calculates relativePosition difference with next item | [
"Method",
"that",
"calculates",
"relativePosition",
"difference",
"with",
"next",
"item"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L287-L296 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(items) {
if(!items)
return;
var positions;
if(this.settings.orientation == 'horizontal')
positions = ['top', 'bottom'];
else
positions = ['left', 'right'];
for(var i = 0; i < this.content.length; i++) ... | javascript | function(items) {
if(!items)
return;
var positions;
if(this.settings.orientation == 'horizontal')
positions = ['top', 'bottom'];
else
positions = ['left', 'right'];
for(var i = 0; i < this.content.length; i++) ... | [
"function",
"(",
"items",
")",
"{",
"if",
"(",
"!",
"items",
")",
"return",
";",
"var",
"positions",
";",
"if",
"(",
"this",
".",
"settings",
".",
"orientation",
"==",
"'horizontal'",
")",
"positions",
"=",
"[",
"'top'",
",",
"'bottom'",
"]",
";",
"e... | Method that fill 'position' field, depending on item's forcePosition option, on item's type and on position of the previous item | [
"Method",
"that",
"fill",
"position",
"field",
"depending",
"on",
"item",
"s",
"forcePosition",
"option",
"on",
"item",
"s",
"type",
"and",
"on",
"position",
"of",
"the",
"previous",
"item"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L334-L376 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(item) {
if(!item || (item && !item.element) || (item && !item.position))
return;
switch(item.position) {
case 'left':
item.element
.removeClass('timeline-me-top')
.removeClass('timeline-me-right... | javascript | function(item) {
if(!item || (item && !item.element) || (item && !item.position))
return;
switch(item.position) {
case 'left':
item.element
.removeClass('timeline-me-top')
.removeClass('timeline-me-right... | [
"function",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"item",
"||",
"(",
"item",
"&&",
"!",
"item",
".",
"element",
")",
"||",
"(",
"item",
"&&",
"!",
"item",
".",
"position",
")",
")",
"return",
";",
"switch",
"(",
"item",
".",
"position",
")",
"... | Method that refresh item's class depending on its 'position' property | [
"Method",
"that",
"refresh",
"item",
"s",
"class",
"depending",
"on",
"its",
"position",
"property"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L379-L415 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(item) {
var itemElm;
switch(item.type) {
case 'milestone':
itemElm = this._buildMilestoneElement(item);
break;
case 'smallItem':
itemElm = this._buildSmallItemElement(item);
b... | javascript | function(item) {
var itemElm;
switch(item.type) {
case 'milestone':
itemElm = this._buildMilestoneElement(item);
break;
case 'smallItem':
itemElm = this._buildSmallItemElement(item);
b... | [
"function",
"(",
"item",
")",
"{",
"var",
"itemElm",
";",
"switch",
"(",
"item",
".",
"type",
")",
"{",
"case",
"'milestone'",
":",
"itemElm",
"=",
"this",
".",
"_buildMilestoneElement",
"(",
"item",
")",
";",
"break",
";",
"case",
"'smallItem'",
":",
... | Method that create the item's html structure and fill it | [
"Method",
"that",
"create",
"the",
"item",
"s",
"html",
"structure",
"and",
"fill",
"it"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L418-L453 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(item) {
if(!item || !item.element)
return;
var pixelsRegex = /[0-9]+px$/;
// Following wrapper are only used in horizontal mode, in order to correctly display bigItems (with table display)
var itemWrapper = $('<div class="timeline-me-item-wrapper... | javascript | function(item) {
if(!item || !item.element)
return;
var pixelsRegex = /[0-9]+px$/;
// Following wrapper are only used in horizontal mode, in order to correctly display bigItems (with table display)
var itemWrapper = $('<div class="timeline-me-item-wrapper... | [
"function",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"item",
"||",
"!",
"item",
".",
"element",
")",
"return",
";",
"var",
"pixelsRegex",
"=",
"/",
"[0-9]+px$",
"/",
";",
"// Following wrapper are only used in horizontal mode, in order to correctly display bigItems (wit... | Method that fills the item's element with some useful html structure | [
"Method",
"that",
"fills",
"the",
"item",
"s",
"element",
"with",
"some",
"useful",
"html",
"structure"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L474-L526 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(item) {
if(!item || !item.type || !item.element)
return false;
switch(item.type) {
case 'milestone':
return (item.element.hasClass('timeline-milestone'));
break;
case 'smallItem':
... | javascript | function(item) {
if(!item || !item.type || !item.element)
return false;
switch(item.type) {
case 'milestone':
return (item.element.hasClass('timeline-milestone'));
break;
case 'smallItem':
... | [
"function",
"(",
"item",
")",
"{",
"if",
"(",
"!",
"item",
"||",
"!",
"item",
".",
"type",
"||",
"!",
"item",
".",
"element",
")",
"return",
"false",
";",
"switch",
"(",
"item",
".",
"type",
")",
"{",
"case",
"'milestone'",
":",
"return",
"(",
"i... | Method that checks if an item's element has the class defined by his type | [
"Method",
"that",
"checks",
"if",
"an",
"item",
"s",
"element",
"has",
"the",
"class",
"defined",
"by",
"his",
"type"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L648-L666 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(leftScrollElm, rightScrollElm, elmToScroll, scrollSpeed) {
var scrollSpeed = scrollSpeed ? scrollSpeed : 5;
leftScrollElm.on('mouseenter', function() {
var timer = setInterval(function() {
elmToScroll.scrollLeft(elmToScroll.scrollLeft() - scrollSpeed);
}... | javascript | function(leftScrollElm, rightScrollElm, elmToScroll, scrollSpeed) {
var scrollSpeed = scrollSpeed ? scrollSpeed : 5;
leftScrollElm.on('mouseenter', function() {
var timer = setInterval(function() {
elmToScroll.scrollLeft(elmToScroll.scrollLeft() - scrollSpeed);
}... | [
"function",
"(",
"leftScrollElm",
",",
"rightScrollElm",
",",
"elmToScroll",
",",
"scrollSpeed",
")",
"{",
"var",
"scrollSpeed",
"=",
"scrollSpeed",
"?",
"scrollSpeed",
":",
"5",
";",
"leftScrollElm",
".",
"on",
"(",
"'mouseenter'",
",",
"function",
"(",
")",
... | These are real private methods. A plugin instance has access to them
@return {[type]}
Method that bind left & right scroll to any scrollable element | [
"These",
"are",
"real",
"private",
"methods",
".",
"A",
"plugin",
"instance",
"has",
"access",
"to",
"them"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L675-L696 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(element) {
if(!element) return;
var children = element.children();
if(children.length <= 0) return;
var totalWidth = 0;
for(var i = 0; i < children.length; i++) {
totalWidth += $(children[i]).width();
}
element.width(totalWidth);
} | javascript | function(element) {
if(!element) return;
var children = element.children();
if(children.length <= 0) return;
var totalWidth = 0;
for(var i = 0; i < children.length; i++) {
totalWidth += $(children[i]).width();
}
element.width(totalWidth);
} | [
"function",
"(",
"element",
")",
"{",
"if",
"(",
"!",
"element",
")",
"return",
";",
"var",
"children",
"=",
"element",
".",
"children",
"(",
")",
";",
"if",
"(",
"children",
".",
"length",
"<=",
"0",
")",
"return",
";",
"var",
"totalWidth",
"=",
"... | Method that return container width depending on children's width | [
"Method",
"that",
"return",
"container",
"width",
"depending",
"on",
"children",
"s",
"width"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L699-L711 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(element, args) {
if(!args)
args = {};
var refreshDelay = args.refreshDelay ? args.refreshDelay : 500;
var previousHeight = args.previousHeight;
var level = args.level ? args.level : 0;
var ret = new $.Deferred();
var elmHeight;
if(element)
... | javascript | function(element, args) {
if(!args)
args = {};
var refreshDelay = args.refreshDelay ? args.refreshDelay : 500;
var previousHeight = args.previousHeight;
var level = args.level ? args.level : 0;
var ret = new $.Deferred();
var elmHeight;
if(element)
... | [
"function",
"(",
"element",
",",
"args",
")",
"{",
"if",
"(",
"!",
"args",
")",
"args",
"=",
"{",
"}",
";",
"var",
"refreshDelay",
"=",
"args",
".",
"refreshDelay",
"?",
"args",
".",
"refreshDelay",
":",
"500",
";",
"var",
"previousHeight",
"=",
"arg... | Method that can return an element's height when it's changing | [
"Method",
"that",
"can",
"return",
"an",
"element",
"s",
"height",
"when",
"it",
"s",
"changing"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L757-L781 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(items, propertyName) {
if(!items) return false;
var hasProperty = true;
for(var i = 0; i < items.length; i++) {
if(isNaN(items[i][propertyName]))
hasProperty = false;
}
return hasProperty;
} | javascript | function(items, propertyName) {
if(!items) return false;
var hasProperty = true;
for(var i = 0; i < items.length; i++) {
if(isNaN(items[i][propertyName]))
hasProperty = false;
}
return hasProperty;
} | [
"function",
"(",
"items",
",",
"propertyName",
")",
"{",
"if",
"(",
"!",
"items",
")",
"return",
"false",
";",
"var",
"hasProperty",
"=",
"true",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"length",
";",
"i",
"++",
")",
... | Method checking if all items of an array have a specific number property | [
"Method",
"checking",
"if",
"all",
"items",
"of",
"an",
"array",
"have",
"a",
"specific",
"number",
"property"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L799-L808 | train | |
mickaelr/jquery-timelineMe | src/jquery.timelineMe.js | function(items, propertyName) {
if(!items) return false;
var maxProperty;
for(var i = 0; i < items.length; i++) {
if(maxProperty == undefined)
maxProperty = items[i][propertyName];
else if(items[i][propertyName] > maxProperty)
maxProperty ... | javascript | function(items, propertyName) {
if(!items) return false;
var maxProperty;
for(var i = 0; i < items.length; i++) {
if(maxProperty == undefined)
maxProperty = items[i][propertyName];
else if(items[i][propertyName] > maxProperty)
maxProperty ... | [
"function",
"(",
"items",
",",
"propertyName",
")",
"{",
"if",
"(",
"!",
"items",
")",
"return",
"false",
";",
"var",
"maxProperty",
";",
"for",
"(",
"var",
"i",
"=",
"0",
";",
"i",
"<",
"items",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"... | Method returning max value of specific array's property | [
"Method",
"returning",
"max",
"value",
"of",
"specific",
"array",
"s",
"property"
] | b768b43269b3e179037bd80052045b011aac7b38 | https://github.com/mickaelr/jquery-timelineMe/blob/b768b43269b3e179037bd80052045b011aac7b38/src/jquery.timelineMe.js#L811-L822 | train | |
jtrussell/angular-selection-model | examples/vendor/angular-selection-model/selection-model.js | function(event) {
/**
* Set by the `selectionModelIgnore` directive
*
* Use `selectionModelIgnore` to cause `selectionModel` to selectively
* ignore clicks on elements. This is useful if you want to manually
* change a selection when certain thing... | javascript | function(event) {
/**
* Set by the `selectionModelIgnore` directive
*
* Use `selectionModelIgnore` to cause `selectionModel` to selectively
* ignore clicks on elements. This is useful if you want to manually
* change a selection when certain thing... | [
"function",
"(",
"event",
")",
"{",
"/**\r\n * Set by the `selectionModelIgnore` directive\r\n *\r\n * Use `selectionModelIgnore` to cause `selectionModel` to selectively\r\n * ignore clicks on elements. This is useful if you want to manually\r\n * change ... | Item click handler
Use the `ctrl` key to select/deselect while preserving the rest of
your selection. Note your your selection mode must be set to
`'multiple'` to allow for more than one selected item at a time. In
single select mode you still must use the `ctrl` or `shitft` keys to
deselect an item.
The `shift` key ... | [
"Item",
"click",
"handler"
] | ad82c063dadcf41a688be5731ec3044f622489f6 | https://github.com/jtrussell/angular-selection-model/blob/ad82c063dadcf41a688be5731ec3044f622489f6/examples/vendor/angular-selection-model/selection-model.js#L327-L414 | train | |
jtrussell/angular-selection-model | examples/vendor/angular-selection-model/selection-model.js | function() {
if(angular.isArray(selectedItemsList)) {
var ixSmItem = selectedItemsList.indexOf(smItem);
if(smItem[selectedAttribute]) {
if(-1 === ixSmItem) {
selectedItemsList.push(smItem);
}
} else {
if(-1 <... | javascript | function() {
if(angular.isArray(selectedItemsList)) {
var ixSmItem = selectedItemsList.indexOf(smItem);
if(smItem[selectedAttribute]) {
if(-1 === ixSmItem) {
selectedItemsList.push(smItem);
}
} else {
if(-1 <... | [
"function",
"(",
")",
"{",
"if",
"(",
"angular",
".",
"isArray",
"(",
"selectedItemsList",
")",
")",
"{",
"var",
"ixSmItem",
"=",
"selectedItemsList",
".",
"indexOf",
"(",
"smItem",
")",
";",
"if",
"(",
"smItem",
"[",
"selectedAttribute",
"]",
")",
"{",
... | Routine to keep the list of selected items up to date
Adds/removes this item from `selectionModelSelectedItems`. | [
"Routine",
"to",
"keep",
"the",
"list",
"of",
"selected",
"items",
"up",
"to",
"date"
] | ad82c063dadcf41a688be5731ec3044f622489f6 | https://github.com/jtrussell/angular-selection-model/blob/ad82c063dadcf41a688be5731ec3044f622489f6/examples/vendor/angular-selection-model/selection-model.js#L421-L434 | train | |
zohararad/sails-rest | lib/connection.js | runBeforeHooks | function runBeforeHooks(req, method, config, conn, cb){
var httpMethod = conn.connection.methods[method];
async.eachSeries(conn.connection.hooks.before, function (hook, nextHook) {
hook(req, httpMethod, config, conn, function (err) {
if(err) {
return nextHook(err);
}
if(!_.isEmpty(c... | javascript | function runBeforeHooks(req, method, config, conn, cb){
var httpMethod = conn.connection.methods[method];
async.eachSeries(conn.connection.hooks.before, function (hook, nextHook) {
hook(req, httpMethod, config, conn, function (err) {
if(err) {
return nextHook(err);
}
if(!_.isEmpty(c... | [
"function",
"runBeforeHooks",
"(",
"req",
",",
"method",
",",
"config",
",",
"conn",
",",
"cb",
")",
"{",
"var",
"httpMethod",
"=",
"conn",
".",
"connection",
".",
"methods",
"[",
"method",
"]",
";",
"async",
".",
"eachSeries",
"(",
"conn",
".",
"conne... | Run all hook functions defined on `connection.hooks.before`.
Used to modify request properties before running the actual request.
Creates a SuperAgent Request object as soon as `config.endpoint` is defined by one of the hooks.
@note When using your own hooks, please ensure the first hook in the chain defines `config.e... | [
"Run",
"all",
"hook",
"functions",
"defined",
"on",
"connection",
".",
"hooks",
".",
"before",
".",
"Used",
"to",
"modify",
"request",
"properties",
"before",
"running",
"the",
"actual",
"request",
".",
"Creates",
"a",
"SuperAgent",
"Request",
"object",
"as",
... | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/lib/connection.js#L27-L47 | train |
zohararad/sails-rest | lib/connection.js | runAfterHooks | function runAfterHooks(connection, err, res, cb){
async.eachSeries(connection.hooks.after, function (hook, nextHook) {
hook(err, res, nextHook);
}, cb);
} | javascript | function runAfterHooks(connection, err, res, cb){
async.eachSeries(connection.hooks.after, function (hook, nextHook) {
hook(err, res, nextHook);
}, cb);
} | [
"function",
"runAfterHooks",
"(",
"connection",
",",
"err",
",",
"res",
",",
"cb",
")",
"{",
"async",
".",
"eachSeries",
"(",
"connection",
".",
"hooks",
".",
"after",
",",
"function",
"(",
"hook",
",",
"nextHook",
")",
"{",
"hook",
"(",
"err",
",",
... | Run all hook functions defined on `connection.hooks.after`.
Used to modify the response object and optionally handle any relevant errors if any.
@param {Object} connection - connection configuration object
@param {Error} err - response error object
@param {Response} res - SuperAgent HTTP Response object
@param {Functio... | [
"Run",
"all",
"hook",
"functions",
"defined",
"on",
"connection",
".",
"hooks",
".",
"after",
".",
"Used",
"to",
"modify",
"the",
"response",
"object",
"and",
"optionally",
"handle",
"any",
"relevant",
"errors",
"if",
"any",
"."
] | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/lib/connection.js#L57-L61 | train |
zohararad/sails-rest | lib/connection.js | setRequestHeaders | function setRequestHeaders(connection, req) {
if(_.isObject(connection.headers)){
req.set(connection.headers);
}
} | javascript | function setRequestHeaders(connection, req) {
if(_.isObject(connection.headers)){
req.set(connection.headers);
}
} | [
"function",
"setRequestHeaders",
"(",
"connection",
",",
"req",
")",
"{",
"if",
"(",
"_",
".",
"isObject",
"(",
"connection",
".",
"headers",
")",
")",
"{",
"req",
".",
"set",
"(",
"connection",
".",
"headers",
")",
";",
"}",
"}"
] | Sets headers on request object before issuing an HTTP request.
@param {Object} connection - Waterline connection configuration object
@param {Request} req - SuperAgent HTTP Request object | [
"Sets",
"headers",
"on",
"request",
"object",
"before",
"issuing",
"an",
"HTTP",
"request",
"."
] | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/lib/connection.js#L68-L72 | train |
zohararad/sails-rest | lib/connection.js | handleResponse | function handleResponse(connection, err, res, cb) {
runAfterHooks(connection, err, res, function (errFromHooks) {
if(errFromHooks) {
return cb(errFromHooks, null);
} else if (res === undefined) {
cb(err, null);
} else {
cb(err, res.body);
}
});
} | javascript | function handleResponse(connection, err, res, cb) {
runAfterHooks(connection, err, res, function (errFromHooks) {
if(errFromHooks) {
return cb(errFromHooks, null);
} else if (res === undefined) {
cb(err, null);
} else {
cb(err, res.body);
}
});
} | [
"function",
"handleResponse",
"(",
"connection",
",",
"err",
",",
"res",
",",
"cb",
")",
"{",
"runAfterHooks",
"(",
"connection",
",",
"err",
",",
"res",
",",
"function",
"(",
"errFromHooks",
")",
"{",
"if",
"(",
"errFromHooks",
")",
"{",
"return",
"cb",... | Handle SuperAgent HTTP Response. Calls hook functions followed by Waterline callback.
@param {Object} connection - connection configuration object
@param {Error} err - response error object
@param {Response} res - SuperAgent HTTP Response object
@param {Function} cb - function to call with query results. | [
"Handle",
"SuperAgent",
"HTTP",
"Response",
".",
"Calls",
"hook",
"functions",
"followed",
"by",
"Waterline",
"callback",
"."
] | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/lib/connection.js#L81-L91 | train |
zohararad/sails-rest | lib/connection.js | getResponseHandler | function getResponseHandler(connection, cb) {
return function (err, res) {
if (res && !err) {
err = null;
}
handleResponse(connection, err, res, cb);
}
} | javascript | function getResponseHandler(connection, cb) {
return function (err, res) {
if (res && !err) {
err = null;
}
handleResponse(connection, err, res, cb);
}
} | [
"function",
"getResponseHandler",
"(",
"connection",
",",
"cb",
")",
"{",
"return",
"function",
"(",
"err",
",",
"res",
")",
"{",
"if",
"(",
"res",
"&&",
"!",
"err",
")",
"{",
"err",
"=",
"null",
";",
"}",
"handleResponse",
"(",
"connection",
",",
"e... | Creates a generic, anonymous HTTP response handler to handle SuperAgent responses.
@param {Object} connection - Waterline connection configuration object
@param {Function} cb - function to call with query results.
@returns {Function} SuperAgent response handler | [
"Creates",
"a",
"generic",
"anonymous",
"HTTP",
"response",
"handler",
"to",
"handle",
"SuperAgent",
"responses",
"."
] | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/lib/connection.js#L99-L106 | train |
zohararad/sails-rest | lib/hooks.js | castRecordDateFields | function castRecordDateFields(record) {
_.forEach(record, function (value, key) {
if(_.isString(value) && iso.test(value)){
record[key] = new Date(value);
}
});
} | javascript | function castRecordDateFields(record) {
_.forEach(record, function (value, key) {
if(_.isString(value) && iso.test(value)){
record[key] = new Date(value);
}
});
} | [
"function",
"castRecordDateFields",
"(",
"record",
")",
"{",
"_",
".",
"forEach",
"(",
"record",
",",
"function",
"(",
"value",
",",
"key",
")",
"{",
"if",
"(",
"_",
".",
"isString",
"(",
"value",
")",
"&&",
"iso",
".",
"test",
"(",
"value",
")",
"... | Convert ISO formatted strings on response object into Javascript Date objects.
Used to cast date fields returned from HTTP response into their correct Date type.
@param {Object} record - response record object to process. | [
"Convert",
"ISO",
"formatted",
"strings",
"on",
"response",
"object",
"into",
"Javascript",
"Date",
"objects",
".",
"Used",
"to",
"cast",
"date",
"fields",
"returned",
"from",
"HTTP",
"response",
"into",
"their",
"correct",
"Date",
"type",
"."
] | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/lib/hooks.js#L64-L70 | train |
zohararad/sails-rest | lib/hooks.js | processResponse | function processResponse(err, res, cb){
if(!err) {
if(Array.isArray(res.body)){
res.body.forEach(function (body) {
castRecordDateFields(body);
});
} else if (_.isObject(res.body)) {
castRecordDateFields(res.body);
}
}
cb();
} | javascript | function processResponse(err, res, cb){
if(!err) {
if(Array.isArray(res.body)){
res.body.forEach(function (body) {
castRecordDateFields(body);
});
} else if (_.isObject(res.body)) {
castRecordDateFields(res.body);
}
}
cb();
} | [
"function",
"processResponse",
"(",
"err",
",",
"res",
",",
"cb",
")",
"{",
"if",
"(",
"!",
"err",
")",
"{",
"if",
"(",
"Array",
".",
"isArray",
"(",
"res",
".",
"body",
")",
")",
"{",
"res",
".",
"body",
".",
"forEach",
"(",
"function",
"(",
"... | Process HTTP response. Converts response objects date fields from Strings to Dates.
@param {Error} err - HTTP response error
@param {Response} res - SuperAgent HTTP Response object
@param {Function} cb - function that is called when this hook finishes | [
"Process",
"HTTP",
"response",
".",
"Converts",
"response",
"objects",
"date",
"fields",
"from",
"Strings",
"to",
"Dates",
"."
] | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/lib/hooks.js#L78-L89 | train |
zohararad/sails-rest | examples/User.js | function (path, query, cb) {
var httpMethod = 'get',
config = User.datastore.config,
endpoint = url.format({
host: config.host,
pathname: path,
protocol: config.protocol,
query: query
}),
req = ... | javascript | function (path, query, cb) {
var httpMethod = 'get',
config = User.datastore.config,
endpoint = url.format({
host: config.host,
pathname: path,
protocol: config.protocol,
query: query
}),
req = ... | [
"function",
"(",
"path",
",",
"query",
",",
"cb",
")",
"{",
"var",
"httpMethod",
"=",
"'get'",
",",
"config",
"=",
"User",
".",
"datastore",
".",
"config",
",",
"endpoint",
"=",
"url",
".",
"format",
"(",
"{",
"host",
":",
"config",
".",
"host",
",... | Send an arbitrary GET query to REST backend
@param path request path
@param query request query-string object `{paramA: "valueA"}`
@param cb request end callback. See https://github.com/visionmedia/superagent | [
"Send",
"an",
"arbitrary",
"GET",
"query",
"to",
"REST",
"backend"
] | 484898cec7af6c1d4eaff4cad100037d794edd37 | https://github.com/zohararad/sails-rest/blob/484898cec7af6c1d4eaff4cad100037d794edd37/examples/User.js#L22-L33 | train | |
JustBlackBird/gulp-phpcs | reporters/file.js | function(callback) {
var stream = this;
// We don't need to write an empty file.
if (collectedErrors.length === 0) {
callback();
return;
}
var report = collectedErrors.join('\n\n').trim() + '\n';
// Write the err... | javascript | function(callback) {
var stream = this;
// We don't need to write an empty file.
if (collectedErrors.length === 0) {
callback();
return;
}
var report = collectedErrors.join('\n\n').trim() + '\n';
// Write the err... | [
"function",
"(",
"callback",
")",
"{",
"var",
"stream",
"=",
"this",
";",
"// We don't need to write an empty file.",
"if",
"(",
"collectedErrors",
".",
"length",
"===",
"0",
")",
"{",
"callback",
"(",
")",
";",
"return",
";",
"}",
"var",
"report",
"=",
"c... | After we collected all errors, output them to the defined file. | [
"After",
"we",
"collected",
"all",
"errors",
"output",
"them",
"to",
"the",
"defined",
"file",
"."
] | fd0424a59c1d825ef60eb9c8e9df158eba0c9913 | https://github.com/JustBlackBird/gulp-phpcs/blob/fd0424a59c1d825ef60eb9c8e9df158eba0c9913/reporters/file.js#L38-L71 | train | |
evanhuang8/iorejson | lib/rejson.js | Rejson | function Rejson(opts) {
// Instantiation
if (!(this instanceof Rejson)) {
return new Rejson(opts);
}
EventEmitter.call(this);
opts = opts || {};
_.defaults(opts, Rejson.defaultOptions);
var redis = new Redis(opts);
// Add new commands
this.cmds = {};
for (var i in Rejson.commands) {
var... | javascript | function Rejson(opts) {
// Instantiation
if (!(this instanceof Rejson)) {
return new Rejson(opts);
}
EventEmitter.call(this);
opts = opts || {};
_.defaults(opts, Rejson.defaultOptions);
var redis = new Redis(opts);
// Add new commands
this.cmds = {};
for (var i in Rejson.commands) {
var... | [
"function",
"Rejson",
"(",
"opts",
")",
"{",
"// Instantiation",
"if",
"(",
"!",
"(",
"this",
"instanceof",
"Rejson",
")",
")",
"{",
"return",
"new",
"Rejson",
"(",
"opts",
")",
";",
"}",
"EventEmitter",
".",
"call",
"(",
"this",
")",
";",
"opts",
"=... | Creates a Rejson instance
@constructor | [
"Creates",
"a",
"Rejson",
"instance"
] | 2a8d095b821888b24ceb9014322c91b0a255ec7e | https://github.com/evanhuang8/iorejson/blob/2a8d095b821888b24ceb9014322c91b0a255ec7e/lib/rejson.js#L12-L41 | train |
JustBlackBird/gulp-phpcs | reporters/fail.js | function(file, enc, callback) {
var report = file.phpcsReport || {};
if (report.error) {
phpcsError = true;
if (options.failOnFirst) {
var errorMessage = 'PHP Code Sniffer failed' +
' on ' + chalk.magenta(file.path);
... | javascript | function(file, enc, callback) {
var report = file.phpcsReport || {};
if (report.error) {
phpcsError = true;
if (options.failOnFirst) {
var errorMessage = 'PHP Code Sniffer failed' +
' on ' + chalk.magenta(file.path);
... | [
"function",
"(",
"file",
",",
"enc",
",",
"callback",
")",
"{",
"var",
"report",
"=",
"file",
".",
"phpcsReport",
"||",
"{",
"}",
";",
"if",
"(",
"report",
".",
"error",
")",
"{",
"phpcsError",
"=",
"true",
";",
"if",
"(",
"options",
".",
"failOnFi... | Watch for errors | [
"Watch",
"for",
"errors"
] | fd0424a59c1d825ef60eb9c8e9df158eba0c9913 | https://github.com/JustBlackBird/gulp-phpcs/blob/fd0424a59c1d825ef60eb9c8e9df158eba0c9913/reporters/fail.js#L25-L46 | train | |
JustBlackBird/gulp-phpcs | reporters/fail.js | function(callback) {
// We have to check "failOnFirst" flag to make sure we did not
// throw the error before.
if (phpcsError && !options.failOnFirst) {
this.emit('error', new gutil.PluginError(
'gulp-phpcs',
'PHP Code Sniffer f... | javascript | function(callback) {
// We have to check "failOnFirst" flag to make sure we did not
// throw the error before.
if (phpcsError && !options.failOnFirst) {
this.emit('error', new gutil.PluginError(
'gulp-phpcs',
'PHP Code Sniffer f... | [
"function",
"(",
"callback",
")",
"{",
"// We have to check \"failOnFirst\" flag to make sure we did not",
"// throw the error before.",
"if",
"(",
"phpcsError",
"&&",
"!",
"options",
".",
"failOnFirst",
")",
"{",
"this",
".",
"emit",
"(",
"'error'",
",",
"new",
"guti... | Abort if we had at least one error. | [
"Abort",
"if",
"we",
"had",
"at",
"least",
"one",
"error",
"."
] | fd0424a59c1d825ef60eb9c8e9df158eba0c9913 | https://github.com/JustBlackBird/gulp-phpcs/blob/fd0424a59c1d825ef60eb9c8e9df158eba0c9913/reporters/fail.js#L49-L60 | train | |
san650/ember-web-app | lib/utils/includes.js | includes | function includes(array, element) {
if (!array) {
return false;
}
const length = array.length;
for (let i = 0; i < length; i++) {
if (array[i] === element) {
return true;
}
}
return false;
} | javascript | function includes(array, element) {
if (!array) {
return false;
}
const length = array.length;
for (let i = 0; i < length; i++) {
if (array[i] === element) {
return true;
}
}
return false;
} | [
"function",
"includes",
"(",
"array",
",",
"element",
")",
"{",
"if",
"(",
"!",
"array",
")",
"{",
"return",
"false",
";",
"}",
"const",
"length",
"=",
"array",
".",
"length",
";",
"for",
"(",
"let",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
... | Polyfill for Array.prototype.includes for Node.js < 6 | [
"Polyfill",
"for",
"Array",
".",
"prototype",
".",
"includes",
"for",
"Node",
".",
"js",
"<",
"6"
] | df3120686064c3daf01fd9472a08d2c26afb979d | https://github.com/san650/ember-web-app/blob/df3120686064c3daf01fd9472a08d2c26afb979d/lib/utils/includes.js#L6-L20 | train |
magicmonkey/lifxjs | lifx.js | getMyIPs | function getMyIPs() {
var ips = [];
var ifs = os.networkInterfaces();
for (var i in ifs) {
for (var j in ifs[i]) {
ips.push(ifs[i][j].address);
}
}
return ips;
} | javascript | function getMyIPs() {
var ips = [];
var ifs = os.networkInterfaces();
for (var i in ifs) {
for (var j in ifs[i]) {
ips.push(ifs[i][j].address);
}
}
return ips;
} | [
"function",
"getMyIPs",
"(",
")",
"{",
"var",
"ips",
"=",
"[",
"]",
";",
"var",
"ifs",
"=",
"os",
".",
"networkInterfaces",
"(",
")",
";",
"for",
"(",
"var",
"i",
"in",
"ifs",
")",
"{",
"for",
"(",
"var",
"j",
"in",
"ifs",
"[",
"i",
"]",
")",... | Utility method to get a list of local IP addresses | [
"Utility",
"method",
"to",
"get",
"a",
"list",
"of",
"local",
"IP",
"addresses"
] | cfb4814d447d119a4db410274499d8ee77f66d96 | https://github.com/magicmonkey/lifxjs/blob/cfb4814d447d119a4db410274499d8ee77f66d96/lifx.js#L238-L247 | train |
OpenSTFoundation/openst-platform | lib/contract_interact/openst_utility.js | function (contractAddress) {
// Helpful while deployement, since ENV variables are not set at that time
contractAddress = contractAddress || openSTUtilityContractAddr;
const oThis = this;
oThis.contractAddress = contractAddress;
openSTUtilityContractObj.options.address = contractAddress;
//openSTUtilityC... | javascript | function (contractAddress) {
// Helpful while deployement, since ENV variables are not set at that time
contractAddress = contractAddress || openSTUtilityContractAddr;
const oThis = this;
oThis.contractAddress = contractAddress;
openSTUtilityContractObj.options.address = contractAddress;
//openSTUtilityC... | [
"function",
"(",
"contractAddress",
")",
"{",
"// Helpful while deployement, since ENV variables are not set at that time",
"contractAddress",
"=",
"contractAddress",
"||",
"openSTUtilityContractAddr",
";",
"const",
"oThis",
"=",
"this",
";",
"oThis",
".",
"contractAddress",
... | OpenST Utility Contract constructor
@constructor
@augments OwnedKlass
@param {string} contractAddress - address on Utility Chain where Contract has been deployed | [
"OpenST",
"Utility",
"Contract",
"constructor"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/openst_utility.js#L41-L54 | train | |
OpenSTFoundation/openst-platform | helpers/custom_console_logger.js | function (message) {
var newMessage = "";
if (requestNamespace) {
if (requestNamespace.get('reqId')) {
newMessage += "[" + requestNamespace.get('reqId') + "]";
}
if (requestNamespace.get('workerId')) {
newMessage += "[Worker - " + requestNamespace.get('workerId') + "]";
}
const hrTim... | javascript | function (message) {
var newMessage = "";
if (requestNamespace) {
if (requestNamespace.get('reqId')) {
newMessage += "[" + requestNamespace.get('reqId') + "]";
}
if (requestNamespace.get('workerId')) {
newMessage += "[Worker - " + requestNamespace.get('workerId') + "]";
}
const hrTim... | [
"function",
"(",
"message",
")",
"{",
"var",
"newMessage",
"=",
"\"\"",
";",
"if",
"(",
"requestNamespace",
")",
"{",
"if",
"(",
"requestNamespace",
".",
"get",
"(",
"'reqId'",
")",
")",
"{",
"newMessage",
"+=",
"\"[\"",
"+",
"requestNamespace",
".",
"ge... | Method to append Request in each log line.
@param {string} message | [
"Method",
"to",
"append",
"Request",
"in",
"each",
"log",
"line",
"."
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/helpers/custom_console_logger.js#L43-L57 | train | |
OpenSTFoundation/openst-platform | services/approve/branded_token.js | function (params) {
const oThis = this;
params = params || {};
oThis.erc20Address = params.erc20_address;
oThis.approverAddress = params.approver_address;
oThis.approverPassphrase = params.approver_passphrase;
oThis.approveeAddress = params.approvee_address;
oThis.toApproveAmount = new BigNumber(params.t... | javascript | function (params) {
const oThis = this;
params = params || {};
oThis.erc20Address = params.erc20_address;
oThis.approverAddress = params.approver_address;
oThis.approverPassphrase = params.approver_passphrase;
oThis.approveeAddress = params.approvee_address;
oThis.toApproveAmount = new BigNumber(params.t... | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"erc20Address",
"=",
"params",
".",
"erc20_address",
";",
"oThis",
".",
"approverAddress",
"=",
"params",
".",
"approver_... | Approve for spending Branded Token
@param {object} params
@param {string} params.erc20_address - Branded token EIP20 address
@param {string} params.approver_address - Approver address
@param {string} params.approver_passphrase - Approver passphrase
@param {string} params.approvee_address - Approvee address
@param {num... | [
"Approve",
"for",
"spending",
"Branded",
"Token"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/approve/branded_token.js#L32-L42 | train | |
OpenSTFoundation/openst-platform | services/stake_and_mint/approve_openst_value_contract.js | function (params) {
const oThis = this
;
params = params || {};
params.options = params.options || {};
if (params.options.returnType === 'txReceipt') {
oThis.runInAsync = false;
} else {
oThis.runInAsync = true;
}
} | javascript | function (params) {
const oThis = this
;
params = params || {};
params.options = params.options || {};
if (params.options.returnType === 'txReceipt') {
oThis.runInAsync = false;
} else {
oThis.runInAsync = true;
}
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"params",
".",
"options",
"=",
"params",
".",
"options",
"||",
"{",
"}",
";",
"if",
"(",
"params",
".",
"options",
".",
"returnTy... | Approve OpenST Value Contract Service
@param {object} params -
@param {object} params.options -
@param {string} params.options.returnType - Desired return type. possible values: uuid, txHash, txReceipt. Default: txHash
@constructor | [
"Approve",
"OpenST",
"Value",
"Contract",
"Service"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/stake_and_mint/approve_openst_value_contract.js#L35-L49 | train | |
OpenSTFoundation/openst-platform | services/stake_and_mint/approve_openst_value_contract.js | async function (toApproveAmount) {
const oThis = this
;
const approveRsp = await simpleToken.approve(
stakerAddress,
stakerPassphrase,
openSTValueContractAddress,
toApproveAmount,
oThis.runInAsync
);
return Promise.resolve(approveRsp);
} | javascript | async function (toApproveAmount) {
const oThis = this
;
const approveRsp = await simpleToken.approve(
stakerAddress,
stakerPassphrase,
openSTValueContractAddress,
toApproveAmount,
oThis.runInAsync
);
return Promise.resolve(approveRsp);
} | [
"async",
"function",
"(",
"toApproveAmount",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"const",
"approveRsp",
"=",
"await",
"simpleToken",
".",
"approve",
"(",
"stakerAddress",
",",
"stakerPassphrase",
",",
"openSTValueContractAddress",
",",
"toApproveAmount",
... | Approve OpenSTValue contract for starting the stake and mint process.
@param {BigNumber} toApproveAmount - this is the amount which is used for approval
@return {promise<result>}
@private
@ignore | [
"Approve",
"OpenSTValue",
"contract",
"for",
"starting",
"the",
"stake",
"and",
"mint",
"process",
"."
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/stake_and_mint/approve_openst_value_contract.js#L91-L106 | train | |
OpenSTFoundation/openst-platform | services/stake_and_mint/approve_openst_value_contract.js | function () {
return simpleToken.balanceOf(stakerAddress)
.then(function (result) {
const stBalance = result.data['balance'];
return new BigNumber(stBalance);
})
} | javascript | function () {
return simpleToken.balanceOf(stakerAddress)
.then(function (result) {
const stBalance = result.data['balance'];
return new BigNumber(stBalance);
})
} | [
"function",
"(",
")",
"{",
"return",
"simpleToken",
".",
"balanceOf",
"(",
"stakerAddress",
")",
".",
"then",
"(",
"function",
"(",
"result",
")",
"{",
"const",
"stBalance",
"=",
"result",
".",
"data",
"[",
"'balance'",
"]",
";",
"return",
"new",
"BigNum... | Get ST balance of staker
@return {promise<result>}
@private
@ignore | [
"Get",
"ST",
"balance",
"of",
"staker"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/stake_and_mint/approve_openst_value_contract.js#L115-L122 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/simple_stake.js | function (params) {
this.contractAddress = params.contractAddress;
this.currContract = new web3Provider.eth.Contract(simpleStakeContractAbi, this.contractAddress);
//this.currContract.setProvider(web3Provider.currentProvider);
} | javascript | function (params) {
this.contractAddress = params.contractAddress;
this.currContract = new web3Provider.eth.Contract(simpleStakeContractAbi, this.contractAddress);
//this.currContract.setProvider(web3Provider.currentProvider);
} | [
"function",
"(",
"params",
")",
"{",
"this",
".",
"contractAddress",
"=",
"params",
".",
"contractAddress",
";",
"this",
".",
"currContract",
"=",
"new",
"web3Provider",
".",
"eth",
".",
"Contract",
"(",
"simpleStakeContractAbi",
",",
"this",
".",
"contractAdd... | Constructor to create object of SimpleStakeKlass
@constructor
@param {object} params -
@param {string} params.contractAddress - simple Stake contract address | [
"Constructor",
"to",
"create",
"object",
"of",
"SimpleStakeKlass"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/simple_stake.js#L31-L39 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/simple_stake.js | function () {
const oThis = this;
const callback = async function (response) {
if (response.isFailure()) {
return response;
}
return responseHelper.successWithData({allTimeStakedAmount: response.data.getTotalStake});
};
return oThis._callMethod('getTotalStake').then(callback... | javascript | function () {
const oThis = this;
const callback = async function (response) {
if (response.isFailure()) {
return response;
}
return responseHelper.successWithData({allTimeStakedAmount: response.data.getTotalStake});
};
return oThis._callMethod('getTotalStake').then(callback... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"const",
"callback",
"=",
"async",
"function",
"(",
"response",
")",
"{",
"if",
"(",
"response",
".",
"isFailure",
"(",
")",
")",
"{",
"return",
"response",
";",
"}",
"return",
"responseHel... | Fetch all time staked amount
@return {promise<result>} | [
"Fetch",
"all",
"time",
"staked",
"amount"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/simple_stake.js#L49-L62 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/simple_stake.js | function (methodName, args) {
const oThis = this
, btAddress = oThis.contractAddress
, scope = oThis.currContract.methods
, transactionObject = scope[methodName].apply(scope, (args || []))
, encodeABI = transactionObject.encodeABI()
, transactionOutputs = contractInteractHelper.getTran... | javascript | function (methodName, args) {
const oThis = this
, btAddress = oThis.contractAddress
, scope = oThis.currContract.methods
, transactionObject = scope[methodName].apply(scope, (args || []))
, encodeABI = transactionObject.encodeABI()
, transactionOutputs = contractInteractHelper.getTran... | [
"function",
"(",
"methodName",
",",
"args",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"btAddress",
"=",
"oThis",
".",
"contractAddress",
",",
"scope",
"=",
"oThis",
".",
"currContract",
".",
"methods",
",",
"transactionObject",
"=",
"scope",
"[",
"meth... | Wrapper method to fetch properties
@param {string} methodName - Contract method name
@param {array} args - method arguments
@return {promise<result>}
@ignore | [
"Wrapper",
"method",
"to",
"fetch",
"properties"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/simple_stake.js#L74-L101 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/st_prime.js | function (contractAddress) {
this.contractAddress = contractAddress;
if (this.contractAddress) {
stPrimeContractObj.options.address = this.contractAddress;
}
//stPrimeContractObj.setProvider(web3Provider.currentProvider);
this.currContract = stPrimeContractObj;
} | javascript | function (contractAddress) {
this.contractAddress = contractAddress;
if (this.contractAddress) {
stPrimeContractObj.options.address = this.contractAddress;
}
//stPrimeContractObj.setProvider(web3Provider.currentProvider);
this.currContract = stPrimeContractObj;
} | [
"function",
"(",
"contractAddress",
")",
"{",
"this",
".",
"contractAddress",
"=",
"contractAddress",
";",
"if",
"(",
"this",
".",
"contractAddress",
")",
"{",
"stPrimeContractObj",
".",
"options",
".",
"address",
"=",
"this",
".",
"contractAddress",
";",
"}",... | Constructor for ST Prime Contract Interact
@constructor
@param {string} contractAddress - address where Contract has been deployed | [
"Constructor",
"for",
"ST",
"Prime",
"Contract",
"Interact"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/st_prime.js#L60-L70 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/st_prime.js | async function () {
const oThis = this
, callMethodResult = await oThis._callMethod('uuid')
, response = callMethodResult.data.uuid;
return response[0];
} | javascript | async function () {
const oThis = this
, callMethodResult = await oThis._callMethod('uuid')
, response = callMethodResult.data.uuid;
return response[0];
} | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"callMethodResult",
"=",
"await",
"oThis",
".",
"_callMethod",
"(",
"'uuid'",
")",
",",
"response",
"=",
"callMethodResult",
".",
"data",
".",
"uuid",
";",
"return",
"response",
"[",
... | Get branded token UUID
@return {promise<result>} | [
"Get",
"branded",
"token",
"UUID"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/st_prime.js#L79-L84 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/st_prime.js | async function (senderName, customOptions) {
const oThis = this
, encodedABI = stPrimeContractObj.methods.initialize().encodeABI()
, stPrimeTotalSupplyInWei = web3Provider.utils.toWei(coreConstants.OST_UTILITY_STPRIME_TOTAL_SUPPLY, "ether");
var options = {gasPrice: UC_GAS_PRICE, value: stPrimeTota... | javascript | async function (senderName, customOptions) {
const oThis = this
, encodedABI = stPrimeContractObj.methods.initialize().encodeABI()
, stPrimeTotalSupplyInWei = web3Provider.utils.toWei(coreConstants.OST_UTILITY_STPRIME_TOTAL_SUPPLY, "ether");
var options = {gasPrice: UC_GAS_PRICE, value: stPrimeTota... | [
"async",
"function",
"(",
"senderName",
",",
"customOptions",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"encodedABI",
"=",
"stPrimeContractObj",
".",
"methods",
".",
"initialize",
"(",
")",
".",
"encodeABI",
"(",
")",
",",
"stPrimeTotalSupplyInWei",
"=",
... | Initial Transfer of ST Prime while chain setup
@param {string} senderName - address who is initializing this transfer - named managed key
@param {object} customOptions - custom params for this transaction
@return {promise<result>} | [
"Initial",
"Transfer",
"of",
"ST",
"Prime",
"while",
"chain",
"setup"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/st_prime.js#L125-L141 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/st_prime.js | async function (senderAddress, senderPassphrase, beneficiaryAddress) {
const oThis = this
, encodedABI = oThis.currContract.methods.claim(beneficiaryAddress).encodeABI()
, currentGasPrice = new BigNumber(await web3Provider.eth.getGasPrice())
;
const estimateGasObj = new EstimateGasKlass({
... | javascript | async function (senderAddress, senderPassphrase, beneficiaryAddress) {
const oThis = this
, encodedABI = oThis.currContract.methods.claim(beneficiaryAddress).encodeABI()
, currentGasPrice = new BigNumber(await web3Provider.eth.getGasPrice())
;
const estimateGasObj = new EstimateGasKlass({
... | [
"async",
"function",
"(",
"senderAddress",
",",
"senderPassphrase",
",",
"beneficiaryAddress",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"encodedABI",
"=",
"oThis",
".",
"currContract",
".",
"methods",
".",
"claim",
"(",
"beneficiaryAddress",
")",
".",
"en... | Claim ST' for beneficiary after they are process-minted
@param {string} senderAddress - address of sender
@param {string} senderPassphrase - passphrase of senderAddress
@param {string} beneficiaryAddress - address where funds would be credited
@return {promise<result>} | [
"Claim",
"ST",
"for",
"beneficiary",
"after",
"they",
"are",
"process",
"-",
"minted"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/st_prime.js#L152-L182 | train | |
OpenSTFoundation/openst-platform | services/transaction/get_receipt.js | function (params) {
const oThis = this
;
params = params || {};
oThis.transactionHash = params.transaction_hash;
oThis.chain = params.chain;
oThis.addressToNameMap = params.address_to_name_map || {};
} | javascript | function (params) {
const oThis = this
;
params = params || {};
oThis.transactionHash = params.transaction_hash;
oThis.chain = params.chain;
oThis.addressToNameMap = params.address_to_name_map || {};
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"transactionHash",
"=",
"params",
".",
"transaction_hash",
";",
"oThis",
".",
"chain",
"=",
"params",
".",
"chain",
";"... | Get Transaction Receipt Service
@param {object} params -
@param {string} params.chain - Chain on which transaction was executed
@param {string} params.transaction_hash - Transaction hash for lookup
@param {object} params.address_to_name_map - hash of contract address to contract name
@constructor | [
"Get",
"Transaction",
"Receipt",
"Service"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/transaction/get_receipt.js#L26-L34 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/openst_value.js | function (contractAddress) {
// Helpful while deployement, since ENV variables are not set at that time
contractAddress = contractAddress || openSTValueContractAddr;
this.contractAddress = contractAddress;
openSTValueContractObj.options.address = contractAddress;
//openSTValueContractObj.setProvider(web3Pro... | javascript | function (contractAddress) {
// Helpful while deployement, since ENV variables are not set at that time
contractAddress = contractAddress || openSTValueContractAddr;
this.contractAddress = contractAddress;
openSTValueContractObj.options.address = contractAddress;
//openSTValueContractObj.setProvider(web3Pro... | [
"function",
"(",
"contractAddress",
")",
"{",
"// Helpful while deployement, since ENV variables are not set at that time",
"contractAddress",
"=",
"contractAddress",
"||",
"openSTValueContractAddr",
";",
"this",
".",
"contractAddress",
"=",
"contractAddress",
";",
"openSTValueCo... | OpenST Value Contract constructor
@constructor
@augments OpsManagedKlass
@param {String} contractAddress - address on Value Chain where Contract has been deployed | [
"OpenST",
"Value",
"Contract",
"constructor"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/openst_value.js#L38-L48 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/utility_registrar.js | function (contractAddress) {
const oThis = this;
oThis.contractAddress = contractAddress;
utilityRegistrarContractObj.options.address = oThis.contractAddress;
//utilityRegistrarContractObj.setProvider(web3Provider.currentProvider);
OpsManagedKlass.call(oThis, oThis.contractAddress, web3Provider, utilityReg... | javascript | function (contractAddress) {
const oThis = this;
oThis.contractAddress = contractAddress;
utilityRegistrarContractObj.options.address = oThis.contractAddress;
//utilityRegistrarContractObj.setProvider(web3Provider.currentProvider);
OpsManagedKlass.call(oThis, oThis.contractAddress, web3Provider, utilityReg... | [
"function",
"(",
"contractAddress",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"oThis",
".",
"contractAddress",
"=",
"contractAddress",
";",
"utilityRegistrarContractObj",
".",
"options",
".",
"address",
"=",
"oThis",
".",
"contractAddress",
";",
"//utilityRegi... | Constructor for Utility Registrar Contract Interact
@constructor
@augments OpsManagedKlass
@param {string} contractAddress - address where Contract has been deployed | [
"Constructor",
"for",
"Utility",
"Registrar",
"Contract",
"Interact"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/utility_registrar.js#L38-L47 | train | |
OpenSTFoundation/openst-platform | tools/setup/simple_token_prime/mint.js | function() {
return new Promise(function(onResolve, onReject) {
const getBalance = async function(){
const getSTPBalanceResponse = await fundManager.getSTPrimeBalanceOf(utilityChainOwnerAddr);
if(getSTPBalanceResponse.isSuccess() && (new BigNumber(getSTPBalanceResponse.data.balance)).greate... | javascript | function() {
return new Promise(function(onResolve, onReject) {
const getBalance = async function(){
const getSTPBalanceResponse = await fundManager.getSTPrimeBalanceOf(utilityChainOwnerAddr);
if(getSTPBalanceResponse.isSuccess() && (new BigNumber(getSTPBalanceResponse.data.balance)).greate... | [
"function",
"(",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"onResolve",
",",
"onReject",
")",
"{",
"const",
"getBalance",
"=",
"async",
"function",
"(",
")",
"{",
"const",
"getSTPBalanceResponse",
"=",
"await",
"fundManager",
".",
"getSTPri... | Wait for ST Prime mint
@return {promise}
@private | [
"Wait",
"for",
"ST",
"Prime",
"mint"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/simple_token_prime/mint.js#L89-L107 | train | |
OpenSTFoundation/openst-platform | services/transaction/estimate_gas.js | function (params) {
const oThis = this
;
oThis.contractName = params.contract_name;
oThis.contractAddress = params.contract_address;
oThis.chain = params.chain;
oThis.senderAddress = params.sender_address;
oThis.methodName = params.method_name;
oThis.methodArguments = params.method_arguments;
} | javascript | function (params) {
const oThis = this
;
oThis.contractName = params.contract_name;
oThis.contractAddress = params.contract_address;
oThis.chain = params.chain;
oThis.senderAddress = params.sender_address;
oThis.methodName = params.method_name;
oThis.methodArguments = params.method_arguments;
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"oThis",
".",
"contractName",
"=",
"params",
".",
"contract_name",
";",
"oThis",
".",
"contractAddress",
"=",
"params",
".",
"contract_address",
";",
"oThis",
".",
"chain",
"=",
"para... | Estimate gas for a transaction service constructor
@param {object} params
@param {string} params.contract_name - Name of the contract having the method which needs to be called
@param {string} params.contract_address - Address of the contract
@param {string} params.chain - Chain on which the contract was deployed
@par... | [
"Estimate",
"gas",
"for",
"a",
"transaction",
"service",
"constructor"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/transaction/estimate_gas.js#L35-L45 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/helper.js | function (web3Provider, result) {
return new Promise(function (onResolve, onReject) {
onResolve(web3Provider.eth.abi.decodeParameter('address', result));
});
} | javascript | function (web3Provider, result) {
return new Promise(function (onResolve, onReject) {
onResolve(web3Provider.eth.abi.decodeParameter('address', result));
});
} | [
"function",
"(",
"web3Provider",
",",
"result",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"onResolve",
",",
"onReject",
")",
"{",
"onResolve",
"(",
"web3Provider",
".",
"eth",
".",
"abi",
".",
"decodeParameter",
"(",
"'address'",
",",
"re... | Decode result and typecast it to an Address
@param {web3} web3Provider - It could be value chain or utility chain provider
@param {string} result - current contract address
@return {promise} | [
"Decode",
"result",
"and",
"typecast",
"it",
"to",
"an",
"Address"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/helper.js#L165-L169 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/helper.js | function (web3Provider, result) {
return new Promise(function (onResolve, onReject) {
onResolve(web3Provider.utils.hexToNumber(result));
});
} | javascript | function (web3Provider, result) {
return new Promise(function (onResolve, onReject) {
onResolve(web3Provider.utils.hexToNumber(result));
});
} | [
"function",
"(",
"web3Provider",
",",
"result",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"onResolve",
",",
"onReject",
")",
"{",
"onResolve",
"(",
"web3Provider",
".",
"utils",
".",
"hexToNumber",
"(",
"result",
")",
")",
";",
"}",
")"... | Decode result and typecast it to a Number
@param {web3} web3Provider - It could be value chain or utility chain provider
@param {string} result - current contract address
@return {promise} | [
"Decode",
"result",
"and",
"typecast",
"it",
"to",
"a",
"Number"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/helper.js#L195-L199 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/helper.js | function (web3Provider, transactionHash) {
return new Promise(function (onResolve, onReject) {
// number of times it will attempt to fetch
var maxAttempts = 50;
// time interval
const timeInterval = 15000;
var getReceipt = async function () {
if (maxAttempts > 0) {
... | javascript | function (web3Provider, transactionHash) {
return new Promise(function (onResolve, onReject) {
// number of times it will attempt to fetch
var maxAttempts = 50;
// time interval
const timeInterval = 15000;
var getReceipt = async function () {
if (maxAttempts > 0) {
... | [
"function",
"(",
"web3Provider",
",",
"transactionHash",
")",
"{",
"return",
"new",
"Promise",
"(",
"function",
"(",
"onResolve",
",",
"onReject",
")",
"{",
"// number of times it will attempt to fetch",
"var",
"maxAttempts",
"=",
"50",
";",
"// time interval",
"con... | Get transaction receipt
@param {object} web3Provider - It could be value chain or utility chain provider
@param {string} transactionHash - transaction hash
@return {promise<result>} | [
"Get",
"transaction",
"receipt"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/helper.js#L269-L300 | train | |
OpenSTFoundation/openst-platform | services/utils/generate_address.js | function (params) {
const oThis = this
;
params = params || {};
oThis.passphrase = params.passphrase || '';
oThis.chain = params.chain;
} | javascript | function (params) {
const oThis = this
;
params = params || {};
oThis.passphrase = params.passphrase || '';
oThis.chain = params.chain;
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"passphrase",
"=",
"params",
".",
"passphrase",
"||",
"''",
";",
"oThis",
".",
"chain",
"=",
"params",
".",
"chain",
... | Constructor to generate a new address
@param {object} params
@param {string} params.chain - Chain on which this new address should be generated and stored
@param {string} [params.passphrase] - Passphrase for the new address. Default: blank
@constructor | [
"Constructor",
"to",
"generate",
"a",
"new",
"address"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/utils/generate_address.js#L25-L32 | train | |
OpenSTFoundation/openst-platform | tools/setup/geth_checker.js | function () {
const oThis = this
, promiseArray = [];
return new Promise(async function (onResolve, onReject) {
for (var chain in setupConfig.chains) {
promiseArray.push(oThis._isRunning(chain));
}
return Promise.all(promiseArray).then(onResolve);
});
} | javascript | function () {
const oThis = this
, promiseArray = [];
return new Promise(async function (onResolve, onReject) {
for (var chain in setupConfig.chains) {
promiseArray.push(oThis._isRunning(chain));
}
return Promise.all(promiseArray).then(onResolve);
});
} | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"promiseArray",
"=",
"[",
"]",
";",
"return",
"new",
"Promise",
"(",
"async",
"function",
"(",
"onResolve",
",",
"onReject",
")",
"{",
"for",
"(",
"var",
"chain",
"in",
"setupConfig",
".",
... | Check if chains started mining and are ready
@return {promise} | [
"Check",
"if",
"chains",
"started",
"mining",
"and",
"are",
"ready"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/geth_checker.js#L28-L38 | train | |
OpenSTFoundation/openst-platform | tools/setup/geth_checker.js | function(chain) {
const retryAttempts = 100
, timerInterval = 5000
, chainTimer = {timer: undefined, blockNumber: 0, retryCounter: 0}
, provider = (chain == 'utility' ? web3UtilityProvider : web3ValueProvider)
;
return new Promise(function (onResolve, onReject) {
chainTimer['timer'] ... | javascript | function(chain) {
const retryAttempts = 100
, timerInterval = 5000
, chainTimer = {timer: undefined, blockNumber: 0, retryCounter: 0}
, provider = (chain == 'utility' ? web3UtilityProvider : web3ValueProvider)
;
return new Promise(function (onResolve, onReject) {
chainTimer['timer'] ... | [
"function",
"(",
"chain",
")",
"{",
"const",
"retryAttempts",
"=",
"100",
",",
"timerInterval",
"=",
"5000",
",",
"chainTimer",
"=",
"{",
"timer",
":",
"undefined",
",",
"blockNumber",
":",
"0",
",",
"retryCounter",
":",
"0",
"}",
",",
"provider",
"=",
... | Check if mentioned chain started mining and are ready
@param {string} chain - name of the chain
@return {promise} | [
"Check",
"if",
"mentioned",
"chain",
"started",
"mining",
"and",
"are",
"ready"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/geth_checker.js#L47-L75 | train | |
OpenSTFoundation/openst-platform | tools/setup/start_services.js | async function () {
const oThis = this
, servicesList = [];
var cmd = "ps aux | grep dynamo | grep -v grep | tr -s ' ' | cut -d ' ' -f2";
let processId = shell.exec(cmd).stdout;
if (processId == '') {
// Start Dynamo DB in openST env
let startDynamo = new StartDynamo();
await s... | javascript | async function () {
const oThis = this
, servicesList = [];
var cmd = "ps aux | grep dynamo | grep -v grep | tr -s ' ' | cut -d ' ' -f2";
let processId = shell.exec(cmd).stdout;
if (processId == '') {
// Start Dynamo DB in openST env
let startDynamo = new StartDynamo();
await s... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"servicesList",
"=",
"[",
"]",
";",
"var",
"cmd",
"=",
"\"ps aux | grep dynamo | grep -v grep | tr -s ' ' | cut -d ' ' -f2\"",
";",
"let",
"processId",
"=",
"shell",
".",
"exec",
"(",
"cmd",... | Start all platform services | [
"Start",
"all",
"platform",
"services"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/start_services.js#L35-L109 | train | |
OpenSTFoundation/openst-platform | tools/setup/env_manager.js | function(purpose) {
const oThis = this;
// Create empty ENV file
fileManager.touch(setupConfig.env_vars_file, '#!/bin/sh');
fileManager.append(setupConfig.env_vars_file, '#################');
fileManager.append(setupConfig.env_vars_file, '# opentST Platform Environment file');
fileManager.appen... | javascript | function(purpose) {
const oThis = this;
// Create empty ENV file
fileManager.touch(setupConfig.env_vars_file, '#!/bin/sh');
fileManager.append(setupConfig.env_vars_file, '#################');
fileManager.append(setupConfig.env_vars_file, '# opentST Platform Environment file');
fileManager.appen... | [
"function",
"(",
"purpose",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"// Create empty ENV file",
"fileManager",
".",
"touch",
"(",
"setupConfig",
".",
"env_vars_file",
",",
"'#!/bin/sh'",
")",
";",
"fileManager",
".",
"append",
"(",
"setupConfig",
".",
"e... | Generate ENV file from config.js | [
"Generate",
"ENV",
"file",
"from",
"config",
".",
"js"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/env_manager.js#L24-L58 | train | |
OpenSTFoundation/openst-platform | tools/setup/env_manager.js | function (purpose) {
const oThis = this;
for (var chain in setupConfig.chains) {
// Add comment to ENV
fileManager.append(setupConfig.env_vars_file, "\n# "+chain+" chain");
// Add content
oThis._scanAndPopulateEnvVars(setupConfig.chains[chain],purpose);
}
} | javascript | function (purpose) {
const oThis = this;
for (var chain in setupConfig.chains) {
// Add comment to ENV
fileManager.append(setupConfig.env_vars_file, "\n# "+chain+" chain");
// Add content
oThis._scanAndPopulateEnvVars(setupConfig.chains[chain],purpose);
}
} | [
"function",
"(",
"purpose",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"for",
"(",
"var",
"chain",
"in",
"setupConfig",
".",
"chains",
")",
"{",
"// Add comment to ENV",
"fileManager",
".",
"append",
"(",
"setupConfig",
".",
"env_vars_file",
",",
"\"\\n# ... | Populate all chains related env variables | [
"Populate",
"all",
"chains",
"related",
"env",
"variables"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/env_manager.js#L63-L72 | train | |
OpenSTFoundation/openst-platform | tools/setup/env_manager.js | function () {
const oThis = this;
// Add comment to ENV
fileManager.append(setupConfig.env_vars_file, "\n# Contracts");
for (var address in setupConfig.contracts) {
oThis._scanAndPopulateEnvVars(setupConfig.contracts[address]);
}
} | javascript | function () {
const oThis = this;
// Add comment to ENV
fileManager.append(setupConfig.env_vars_file, "\n# Contracts");
for (var address in setupConfig.contracts) {
oThis._scanAndPopulateEnvVars(setupConfig.contracts[address]);
}
} | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"// Add comment to ENV",
"fileManager",
".",
"append",
"(",
"setupConfig",
".",
"env_vars_file",
",",
"\"\\n# Contracts\"",
")",
";",
"for",
"(",
"var",
"address",
"in",
"setupConfig",
".",
"contra... | Populate all contract address related env variables | [
"Populate",
"all",
"contract",
"address",
"related",
"env",
"variables"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/env_manager.js#L137-L146 | train | |
OpenSTFoundation/openst-platform | services/inter_comm/base.js | function () {
const oThis = this
, clearCacheOfExpr = /(openst-platform\/config\/)|(openst-platform\/lib\/)/
;
Object.keys(require.cache).forEach(function (key) {
if (key.search(clearCacheOfExpr) !== -1) {
delete require.cache[key];
}
});
oThis.setContractObj();
// Re... | javascript | function () {
const oThis = this
, clearCacheOfExpr = /(openst-platform\/config\/)|(openst-platform\/lib\/)/
;
Object.keys(require.cache).forEach(function (key) {
if (key.search(clearCacheOfExpr) !== -1) {
delete require.cache[key];
}
});
oThis.setContractObj();
// Re... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"clearCacheOfExpr",
"=",
"/",
"(openst-platform\\/config\\/)|(openst-platform\\/lib\\/)",
"/",
";",
"Object",
".",
"keys",
"(",
"require",
".",
"cache",
")",
".",
"forEach",
"(",
"function",
"(",
"... | Starts the process of the script with initializing processor | [
"Starts",
"the",
"process",
"of",
"the",
"script",
"with",
"initializing",
"processor"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/inter_comm/base.js#L32-L48 | train | |
OpenSTFoundation/openst-platform | services/inter_comm/base.js | async function () {
const oThis = this
;
try {
const highestBlock = await this.getChainHighestBlock();
// return if nothing more to do.
if (highestBlock - 6 <= oThis.lastProcessedBlock) return oThis.schedule();
// consider case in which last block was not processed completely
... | javascript | async function () {
const oThis = this
;
try {
const highestBlock = await this.getChainHighestBlock();
// return if nothing more to do.
if (highestBlock - 6 <= oThis.lastProcessedBlock) return oThis.schedule();
// consider case in which last block was not processed completely
... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"try",
"{",
"const",
"highestBlock",
"=",
"await",
"this",
".",
"getChainHighestBlock",
"(",
")",
";",
"// return if nothing more to do.",
"if",
"(",
"highestBlock",
"-",
"6",
"<=",
"oTh... | Check for further events | [
"Check",
"for",
"further",
"events"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/inter_comm/base.js#L54-L91 | train | |
OpenSTFoundation/openst-platform | services/inter_comm/base.js | function () {
const oThis = this;
process.on('SIGINT', function () {
logger.info("Received SIGINT, cancelling block scaning");
oThis.interruptSignalObtained = true;
});
process.on('SIGTERM', function () {
logger.info("Received SIGTERM, cancelling block scaning");
oThis.interrupt... | javascript | function () {
const oThis = this;
process.on('SIGINT', function () {
logger.info("Received SIGINT, cancelling block scaning");
oThis.interruptSignalObtained = true;
});
process.on('SIGTERM', function () {
logger.info("Received SIGTERM, cancelling block scaning");
oThis.interrupt... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"process",
".",
"on",
"(",
"'SIGINT'",
",",
"function",
"(",
")",
"{",
"logger",
".",
"info",
"(",
"\"Received SIGINT, cancelling block scaning\"",
")",
";",
"oThis",
".",
"interruptSignalObtained"... | Register interrup signal handlers | [
"Register",
"interrup",
"signal",
"handlers"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/inter_comm/base.js#L97-L108 | train | |
OpenSTFoundation/openst-platform | services/inter_comm/base.js | async function (events) {
const oThis = this
, promiseArray = []
;
// nothing to do
if (!events || events.length === 0) {
oThis.updateIntercomDataFile();
return Promise.resolve();
}
//TODO: last processed transaction index.
for (var i = 0; i < events.length; i++) {
... | javascript | async function (events) {
const oThis = this
, promiseArray = []
;
// nothing to do
if (!events || events.length === 0) {
oThis.updateIntercomDataFile();
return Promise.resolve();
}
//TODO: last processed transaction index.
for (var i = 0; i < events.length; i++) {
... | [
"async",
"function",
"(",
"events",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"promiseArray",
"=",
"[",
"]",
";",
"// nothing to do",
"if",
"(",
"!",
"events",
"||",
"events",
".",
"length",
"===",
"0",
")",
"{",
"oThis",
".",
"updateIntercomDataFile... | Process events array
@param {array} events - events array | [
"Process",
"events",
"array"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/inter_comm/base.js#L116-L161 | train | |
OpenSTFoundation/openst-platform | services/inter_comm/base.js | function () {
const oThis = this
;
oThis.snmData.lastProcessedBlock = oThis.toBlock;
fs.writeFileSync(
oThis.filePath,
JSON.stringify(oThis.snmData),
function (err) {
if (err)
logger.error(err);
}
);
if (oThis.interruptSignalObtained) {
logger.i... | javascript | function () {
const oThis = this
;
oThis.snmData.lastProcessedBlock = oThis.toBlock;
fs.writeFileSync(
oThis.filePath,
JSON.stringify(oThis.snmData),
function (err) {
if (err)
logger.error(err);
}
);
if (oThis.interruptSignalObtained) {
logger.i... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"oThis",
".",
"snmData",
".",
"lastProcessedBlock",
"=",
"oThis",
".",
"toBlock",
";",
"fs",
".",
"writeFileSync",
"(",
"oThis",
".",
"filePath",
",",
"JSON",
".",
"stringify",
"(",
"oThis",
... | Update intercom data file | [
"Update",
"intercom",
"data",
"file"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/inter_comm/base.js#L188-L207 | train | |
OpenSTFoundation/openst-platform | services/utils/platform_status.js | async function () {
const oThis = this
, statusResponse = {chain: {value: false, utility: false}};
// check geth status
for (var chainName in statusResponse.chain) {
var response = await oThis._gethStatus(chainName);
if (response.isSuccess()) {
statusResponse.chain[chainName] = t... | javascript | async function () {
const oThis = this
, statusResponse = {chain: {value: false, utility: false}};
// check geth status
for (var chainName in statusResponse.chain) {
var response = await oThis._gethStatus(chainName);
if (response.isSuccess()) {
statusResponse.chain[chainName] = t... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"statusResponse",
"=",
"{",
"chain",
":",
"{",
"value",
":",
"false",
",",
"utility",
":",
"false",
"}",
"}",
";",
"// check geth status",
"for",
"(",
"var",
"chainName",
"in",
"st... | Check status of all services
@return {promise<result>} | [
"Check",
"status",
"of",
"all",
"services"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/utils/platform_status.js#L29-L46 | train | |
OpenSTFoundation/openst-platform | services/utils/platform_status.js | function (chain) {
const web3Provider = web3ProviderFactory.getProvider(chain, web3ProviderFactory.typeWS)
, retryAttempts = 100
, timerInterval = 5000
, chainTimer = {timer: undefined, blockNumber: 0, retryCounter: 0}
;
if (!web3Provider) {
// this is a error scenario.
let err... | javascript | function (chain) {
const web3Provider = web3ProviderFactory.getProvider(chain, web3ProviderFactory.typeWS)
, retryAttempts = 100
, timerInterval = 5000
, chainTimer = {timer: undefined, blockNumber: 0, retryCounter: 0}
;
if (!web3Provider) {
// this is a error scenario.
let err... | [
"function",
"(",
"chain",
")",
"{",
"const",
"web3Provider",
"=",
"web3ProviderFactory",
".",
"getProvider",
"(",
"chain",
",",
"web3ProviderFactory",
".",
"typeWS",
")",
",",
"retryAttempts",
"=",
"100",
",",
"timerInterval",
"=",
"5000",
",",
"chainTimer",
"... | Check geth status
@param {string} chain - chain name
@return {promise<result>}
@private
@ignore | [
"Check",
"geth",
"status"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/utils/platform_status.js#L57-L102 | train | |
OpenSTFoundation/openst-platform | tools/setup/file_manager.js | function() {
const oThis = this;
// Remove old setup folder
logger.info("* Deleting old openST setup folder");
oThis.rm('');
// Create new setup folder
logger.info("* Creating new openST setup folder");
oThis.mkdir('');
// Create logs setup folder
logger.info("* Creating openST se... | javascript | function() {
const oThis = this;
// Remove old setup folder
logger.info("* Deleting old openST setup folder");
oThis.rm('');
// Create new setup folder
logger.info("* Creating new openST setup folder");
oThis.mkdir('');
// Create logs setup folder
logger.info("* Creating openST se... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"// Remove old setup folder",
"logger",
".",
"info",
"(",
"\"* Deleting old openST setup folder\"",
")",
";",
"oThis",
".",
"rm",
"(",
"''",
")",
";",
"// Create new setup folder",
"logger",
".",
"in... | Do the old setup clean up | [
"Do",
"the",
"old",
"setup",
"clean",
"up"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/file_manager.js#L28-L57 | train | |
OpenSTFoundation/openst-platform | tools/setup/file_manager.js | function(relativePath, fileContent) {
const file = setupHelper.setupFolderAbsolutePath() + '/' + relativePath;
fileContent = fileContent || '';
return setupHelper.handleShellResponse(shell.exec('echo "' + fileContent + '" > ' + file));
} | javascript | function(relativePath, fileContent) {
const file = setupHelper.setupFolderAbsolutePath() + '/' + relativePath;
fileContent = fileContent || '';
return setupHelper.handleShellResponse(shell.exec('echo "' + fileContent + '" > ' + file));
} | [
"function",
"(",
"relativePath",
",",
"fileContent",
")",
"{",
"const",
"file",
"=",
"setupHelper",
".",
"setupFolderAbsolutePath",
"(",
")",
"+",
"'/'",
"+",
"relativePath",
";",
"fileContent",
"=",
"fileContent",
"||",
"''",
";",
"return",
"setupHelper",
"."... | Create file inside openST setup environment
@param {string} relativePath - relative file path
@param {string} fileContent - optional file content | [
"Create",
"file",
"inside",
"openST",
"setup",
"environment"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/file_manager.js#L85-L89 | train | |
OpenSTFoundation/openst-platform | tools/setup/file_manager.js | function(relativePath, line) {
const file = setupHelper.setupFolderAbsolutePath() + '/' + relativePath;
return setupHelper.handleShellResponse(shell.exec('echo "' + line + '" >> ' + file));
} | javascript | function(relativePath, line) {
const file = setupHelper.setupFolderAbsolutePath() + '/' + relativePath;
return setupHelper.handleShellResponse(shell.exec('echo "' + line + '" >> ' + file));
} | [
"function",
"(",
"relativePath",
",",
"line",
")",
"{",
"const",
"file",
"=",
"setupHelper",
".",
"setupFolderAbsolutePath",
"(",
")",
"+",
"'/'",
"+",
"relativePath",
";",
"return",
"setupHelper",
".",
"handleShellResponse",
"(",
"shell",
".",
"exec",
"(",
... | Append line at the end of the file
@param {string} relativePath - relative file path
@param {string} line - line to be appended to file | [
"Append",
"line",
"at",
"the",
"end",
"of",
"the",
"file"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/file_manager.js#L97-L100 | train | |
OpenSTFoundation/openst-platform | tools/setup/file_manager.js | function(fromFolder, toFolder, fileName) {
const src = setupHelper.setupFolderAbsolutePath() + '/' + fromFolder + '/' + fileName
, dest = setupHelper.setupFolderAbsolutePath() + '/' + toFolder + '/';
return setupHelper.handleShellResponse(shell.exec('cp -r ' + src + ' ' + dest));
} | javascript | function(fromFolder, toFolder, fileName) {
const src = setupHelper.setupFolderAbsolutePath() + '/' + fromFolder + '/' + fileName
, dest = setupHelper.setupFolderAbsolutePath() + '/' + toFolder + '/';
return setupHelper.handleShellResponse(shell.exec('cp -r ' + src + ' ' + dest));
} | [
"function",
"(",
"fromFolder",
",",
"toFolder",
",",
"fileName",
")",
"{",
"const",
"src",
"=",
"setupHelper",
".",
"setupFolderAbsolutePath",
"(",
")",
"+",
"'/'",
"+",
"fromFolder",
"+",
"'/'",
"+",
"fileName",
",",
"dest",
"=",
"setupHelper",
".",
"setu... | Copy file from one folder to another inside openST setup environment
@param {string} fromFolder - relative from folder
@param {string} toFolder - relative to folder
@param {string} fileName - file name | [
"Copy",
"file",
"from",
"one",
"folder",
"to",
"another",
"inside",
"openST",
"setup",
"environment"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/file_manager.js#L109-L113 | train | |
OpenSTFoundation/openst-platform | services/transaction/transfer/simple_token.js | function (params) {
const oThis = this
;
params = params || {};
oThis.senderAddress = params.sender_address;
oThis.senderPassphrase = params.sender_passphrase;
oThis.senderName = params.sender_name;
oThis.recipientAddress = params.recipient_address;
oThis.recipientName = params.recipient_name;
oThis... | javascript | function (params) {
const oThis = this
;
params = params || {};
oThis.senderAddress = params.sender_address;
oThis.senderPassphrase = params.sender_passphrase;
oThis.senderName = params.sender_name;
oThis.recipientAddress = params.recipient_address;
oThis.recipientName = params.recipient_name;
oThis... | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"senderAddress",
"=",
"params",
".",
"sender_address",
";",
"oThis",
".",
"senderPassphrase",
"=",
"params",
".",
"sender... | Transfer Simple Token Service
@param {object} params -
@param {string} params.sender_address - Sender address
@param {string} params.sender_passphrase - Sender passphrase
@param {string} [params.sender_name] - Sender name where only platform has address and passphrase
@param {string} params.recipient_address - Recipie... | [
"Transfer",
"Simple",
"Token",
"Service"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/transaction/transfer/simple_token.js#L32-L47 | train | |
OpenSTFoundation/openst-platform | services/balance/branded_token.js | function (params) {
const oThis = this;
params = params || {};
oThis.erc20Address = params.erc20_address;
oThis.address = params.address;
} | javascript | function (params) {
const oThis = this;
params = params || {};
oThis.erc20Address = params.erc20_address;
oThis.address = params.address;
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"erc20Address",
"=",
"params",
".",
"erc20_address",
";",
"oThis",
".",
"address",
"=",
"params",
".",
"address",
";",
... | Branded Token balance
@param {object} params -
@param {string} params.erc20_address - Branded token EIP20 address
@param {string} params.address - Account address
@constructor | [
"Branded",
"Token",
"balance"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/balance/branded_token.js#L24-L30 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/mint.js | function (params) {
const oThis = this
;
oThis.brandedTokenUuid = params.uuid;
oThis.amountToStakeInWeis = params.amount_to_stake_in_weis;
oThis.reserveAddr = params.reserve_address;
oThis.reservePassphrase = params.reserve_passphrase;
oThis.erc20Address = params.erc20_address;
} | javascript | function (params) {
const oThis = this
;
oThis.brandedTokenUuid = params.uuid;
oThis.amountToStakeInWeis = params.amount_to_stake_in_weis;
oThis.reserveAddr = params.reserve_address;
oThis.reservePassphrase = params.reserve_passphrase;
oThis.erc20Address = params.erc20_address;
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"oThis",
".",
"brandedTokenUuid",
"=",
"params",
".",
"uuid",
";",
"oThis",
".",
"amountToStakeInWeis",
"=",
"params",
".",
"amount_to_stake_in_weis",
";",
"oThis",
".",
"reserveAddr",
... | Constructor for Mint Branded Token
@constructor | [
"Constructor",
"for",
"Mint",
"Branded",
"Token"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/mint.js#L37-L46 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/mint.js | function() {
const oThis = this
;
return new Promise(async function(onResolve, onReject) {
// NOTE: NOT Relying on CACHE - this is because for in process memory, this goes into infinite loop
const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
, brande... | javascript | function() {
const oThis = this
;
return new Promise(async function(onResolve, onReject) {
// NOTE: NOT Relying on CACHE - this is because for in process memory, this goes into infinite loop
const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
, brande... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"return",
"new",
"Promise",
"(",
"async",
"function",
"(",
"onResolve",
",",
"onReject",
")",
"{",
"// NOTE: NOT Relying on CACHE - this is because for in process memory, this goes into infinite loop",
"const"... | Wait for Branded Token mint
@return {promise}
@private | [
"Wait",
"for",
"Branded",
"Token",
"mint"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/mint.js#L136-L166 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/mint.js | function() {
const oThis = this
, web3UcProvider = web3ProviderFactory.getProvider('utility', 'ws')
;
return new Promise(async function(onResolve, onReject) {
const beforeBalance = new BigNumber(await web3UcProvider.eth.getBalance(oThis.reserveAddr));
logger.info('Balance of Reserve for... | javascript | function() {
const oThis = this
, web3UcProvider = web3ProviderFactory.getProvider('utility', 'ws')
;
return new Promise(async function(onResolve, onReject) {
const beforeBalance = new BigNumber(await web3UcProvider.eth.getBalance(oThis.reserveAddr));
logger.info('Balance of Reserve for... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"web3UcProvider",
"=",
"web3ProviderFactory",
".",
"getProvider",
"(",
"'utility'",
",",
"'ws'",
")",
";",
"return",
"new",
"Promise",
"(",
"async",
"function",
"(",
"onResolve",
",",
"onReject",... | Wait for Simple Token Prime mint
@return {promise}
@private | [
"Wait",
"for",
"Simple",
"Token",
"Prime",
"mint"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/mint.js#L174-L199 | train | |
nikospara/require-lazy | src/build-scripts/map-path-inverse.js | addPath | function addPath(path, name) {
// This will add a path -> name mapping, so that paths may be later
// resolved to module names, as well as a filesystem full path to
// module mapping, in case the `paths` value contains relative paths
// (e.g. `../`, see issue #2).
var fullPath = (pathModule.normalize(pathModu... | javascript | function addPath(path, name) {
// This will add a path -> name mapping, so that paths may be later
// resolved to module names, as well as a filesystem full path to
// module mapping, in case the `paths` value contains relative paths
// (e.g. `../`, see issue #2).
var fullPath = (pathModule.normalize(pathModu... | [
"function",
"addPath",
"(",
"path",
",",
"name",
")",
"{",
"// This will add a path -> name mapping, so that paths may be later",
"// resolved to module names, as well as a filesystem full path to",
"// module mapping, in case the `paths` value contains relative paths",
"// (e.g. `../`, see is... | Add the module to the inverse path mappings. | [
"Add",
"the",
"module",
"to",
"the",
"inverse",
"path",
"mappings",
"."
] | ef067ebe460bb81dd856e784aaf141d73a17dda5 | https://github.com/nikospara/require-lazy/blob/ef067ebe460bb81dd856e784aaf141d73a17dda5/src/build-scripts/map-path-inverse.js#L41-L49 | train |
OpenSTFoundation/openst-platform | services/stake_and_mint/start_stake.js | function (params) {
const oThis = this
;
params = params || {};
oThis.beneficiary = params.beneficiary;
oThis.toStakeAmount = params.to_stake_amount;
oThis.uuid = params.uuid;
} | javascript | function (params) {
const oThis = this
;
params = params || {};
oThis.beneficiary = params.beneficiary;
oThis.toStakeAmount = params.to_stake_amount;
oThis.uuid = params.uuid;
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"beneficiary",
"=",
"params",
".",
"beneficiary",
";",
"oThis",
".",
"toStakeAmount",
"=",
"params",
".",
"to_stake_amoun... | Start Stake Service constructor
@param {object} params -
@param {string} params.beneficiary - Staked amount beneficiary address
@param {number} params.to_stake_amount - Amount (in wei) to stake
@param {string} params.uuid - Branded Token UUID
@constructor | [
"Start",
"Stake",
"Service",
"constructor"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/stake_and_mint/start_stake.js#L31-L39 | train | |
OpenSTFoundation/openst-platform | services/stake_and_mint/get_approval_status.js | function (params) {
const oThis = this
;
params = params || {};
oThis.transactionHash = params.transaction_hash;
oThis.chain = 'value';
} | javascript | function (params) {
const oThis = this
;
params = params || {};
oThis.transactionHash = params.transaction_hash;
oThis.chain = 'value';
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"transactionHash",
"=",
"params",
".",
"transaction_hash",
";",
"oThis",
".",
"chain",
"=",
"'value'",
";",
"}"
] | Get approval status
@param {object} params -
@param {string} params.transaction_hash - Transaction hash for lookup
@constructor | [
"Get",
"approval",
"status"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/stake_and_mint/get_approval_status.js#L23-L30 | train | |
OpenSTFoundation/openst-platform | tools/setup/performer.js | function (deployPath) {
const envFilePath = setupHelper.setupFolderAbsolutePath() + '/' + setupConfig.env_vars_file
, clearCacheOfExpr = /(openst-platform\/config\/)|(openst-platform\/lib\/)|(openst-platform\/services\/)/;
return new Promise(function (onResolve, onReject) {
// source env
shellSource(en... | javascript | function (deployPath) {
const envFilePath = setupHelper.setupFolderAbsolutePath() + '/' + setupConfig.env_vars_file
, clearCacheOfExpr = /(openst-platform\/config\/)|(openst-platform\/lib\/)|(openst-platform\/services\/)/;
return new Promise(function (onResolve, onReject) {
// source env
shellSource(en... | [
"function",
"(",
"deployPath",
")",
"{",
"const",
"envFilePath",
"=",
"setupHelper",
".",
"setupFolderAbsolutePath",
"(",
")",
"+",
"'/'",
"+",
"setupConfig",
".",
"env_vars_file",
",",
"clearCacheOfExpr",
"=",
"/",
"(openst-platform\\/config\\/)|(openst-platform\\/lib\... | Run the deployer helper service
@param {string} deployPath - contract deployment script path
@return {promise} | [
"Run",
"the",
"deployer",
"helper",
"service"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/performer.js#L210-L231 | train | |
OpenSTFoundation/openst-platform | services/on_boarding/propose_branded_token.js | function (params) {
const oThis = this
;
params = params || {};
oThis.name = params.name;
oThis.symbol = params.symbol;
oThis.conversionFactor = params.conversion_factor;
oThis.conversionRate = null;
oThis.conversionRateDecimals = null;
} | javascript | function (params) {
const oThis = this
;
params = params || {};
oThis.name = params.name;
oThis.symbol = params.symbol;
oThis.conversionFactor = params.conversion_factor;
oThis.conversionRate = null;
oThis.conversionRateDecimals = null;
} | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"params",
"=",
"params",
"||",
"{",
"}",
";",
"oThis",
".",
"name",
"=",
"params",
".",
"name",
";",
"oThis",
".",
"symbol",
"=",
"params",
".",
"symbol",
";",
"oThis",
".",
... | Propose Branded Token Service
@param {object} params -
@param {string} params.name - Branded token name
@param {string} params.symbol - Branded token symbol
@param {string} params.conversion_factor - Conversion factor (1 OST = ? Branded token)
@constructor | [
"Propose",
"Branded",
"Token",
"Service"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/services/on_boarding/propose_branded_token.js#L35-L45 | train | |
OpenSTFoundation/openst-platform | tools/setup/fund_manager.js | async function(senderAddr, senderPassphrase, recipient, amountInWei) {
// TODO: should we have isAsync with UUID (unlock account will take time) and also tag, publish events?
const oThis = this
, web3Provider = web3ProviderFactory.getProvider('value', 'ws')
, gasPrice = coreConstants.OST_VALUE_GAS_P... | javascript | async function(senderAddr, senderPassphrase, recipient, amountInWei) {
// TODO: should we have isAsync with UUID (unlock account will take time) and also tag, publish events?
const oThis = this
, web3Provider = web3ProviderFactory.getProvider('value', 'ws')
, gasPrice = coreConstants.OST_VALUE_GAS_P... | [
"async",
"function",
"(",
"senderAddr",
",",
"senderPassphrase",
",",
"recipient",
",",
"amountInWei",
")",
"{",
"// TODO: should we have isAsync with UUID (unlock account will take time) and also tag, publish events?",
"const",
"oThis",
"=",
"this",
",",
"web3Provider",
"=",
... | Transfer ETH on a particular chain from sender to receiver
@param {string} senderAddr - address of user who is sending amount
@param {string} senderPassphrase - sender address passphrase
@param {string} recipient - address of user who is receiving amount
@param {BigNumber} amountInWei - amount which is being transferr... | [
"Transfer",
"ETH",
"on",
"a",
"particular",
"chain",
"from",
"sender",
"to",
"receiver"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/fund_manager.js#L54-L134 | train | |
OpenSTFoundation/openst-platform | tools/setup/fund_manager.js | function(erc20Address, senderAddr, senderPassphrase, recipient, amountInWei) {
const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
, brandedToken = new BrandedTokenKlass({ERC20: erc20Address})
;
return brandedToken.transfer(senderAddr, senderPassphrase, recipient, ... | javascript | function(erc20Address, senderAddr, senderPassphrase, recipient, amountInWei) {
const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
, brandedToken = new BrandedTokenKlass({ERC20: erc20Address})
;
return brandedToken.transfer(senderAddr, senderPassphrase, recipient, ... | [
"function",
"(",
"erc20Address",
",",
"senderAddr",
",",
"senderPassphrase",
",",
"recipient",
",",
"amountInWei",
")",
"{",
"const",
"BrandedTokenKlass",
"=",
"require",
"(",
"rootPrefix",
"+",
"'/lib/contract_interact/branded_token'",
")",
",",
"brandedToken",
"=",
... | Transfer Branded Token
@param {string} erc20Address - address of erc20 contract address
@param {string} senderAddr - address of user who is sending amount
@param {string} senderPassphrase - sender address passphrase
@param {string} recipient - address of user who is receiving amount
@param {BigNumber} amountInWei - am... | [
"Transfer",
"Branded",
"Token"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/fund_manager.js#L147-L154 | train | |
OpenSTFoundation/openst-platform | tools/setup/fund_manager.js | function (owner) {
const web3Provider = web3ProviderFactory.getProvider('value', 'ws')
;
// Validate addresses
if (!basicHelper.isAddressValid(owner)) {
let errObj = responseHelper.error({
internal_error_identifier: 't_s_fm_8',
api_error_identifier: 'invalid_address',
erro... | javascript | function (owner) {
const web3Provider = web3ProviderFactory.getProvider('value', 'ws')
;
// Validate addresses
if (!basicHelper.isAddressValid(owner)) {
let errObj = responseHelper.error({
internal_error_identifier: 't_s_fm_8',
api_error_identifier: 'invalid_address',
erro... | [
"function",
"(",
"owner",
")",
"{",
"const",
"web3Provider",
"=",
"web3ProviderFactory",
".",
"getProvider",
"(",
"'value'",
",",
"'ws'",
")",
";",
"// Validate addresses",
"if",
"(",
"!",
"basicHelper",
".",
"isAddressValid",
"(",
"owner",
")",
")",
"{",
"l... | Get ETH Balance of an address
@param {string} owner - address
@return {promise<result>} | [
"Get",
"ETH",
"Balance",
"of",
"an",
"address"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/fund_manager.js#L207-L234 | train | |
OpenSTFoundation/openst-platform | tools/setup/fund_manager.js | function (erc20Address, owner) {
const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
, brandedToken = new BrandedTokenKlass({ERC20: erc20Address})
;
return brandedToken.getBalanceOf(owner);
} | javascript | function (erc20Address, owner) {
const BrandedTokenKlass = require(rootPrefix + '/lib/contract_interact/branded_token')
, brandedToken = new BrandedTokenKlass({ERC20: erc20Address})
;
return brandedToken.getBalanceOf(owner);
} | [
"function",
"(",
"erc20Address",
",",
"owner",
")",
"{",
"const",
"BrandedTokenKlass",
"=",
"require",
"(",
"rootPrefix",
"+",
"'/lib/contract_interact/branded_token'",
")",
",",
"brandedToken",
"=",
"new",
"BrandedTokenKlass",
"(",
"{",
"ERC20",
":",
"erc20Address"... | Get Branded Token Balance of an address
@param {string} erc20Address - address of erc20 contract address
@param {string} owner - address
@return {promise<result>} | [
"Get",
"Branded",
"Token",
"Balance",
"of",
"an",
"address"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/fund_manager.js#L298-L304 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/value_registrar.js | function (contractAddress) {
this.contractAddress = contractAddress;
valueRegistrarContractObj.options.address = this.contractAddress;
//valueRegistrarContractObj.setProvider(web3Provider.currentProvider);
OpsManagedKlass.call(this, this.contractAddress, web3Provider, valueRegistrarContractObj, VC_GAS_PRICE)... | javascript | function (contractAddress) {
this.contractAddress = contractAddress;
valueRegistrarContractObj.options.address = this.contractAddress;
//valueRegistrarContractObj.setProvider(web3Provider.currentProvider);
OpsManagedKlass.call(this, this.contractAddress, web3Provider, valueRegistrarContractObj, VC_GAS_PRICE)... | [
"function",
"(",
"contractAddress",
")",
"{",
"this",
".",
"contractAddress",
"=",
"contractAddress",
";",
"valueRegistrarContractObj",
".",
"options",
".",
"address",
"=",
"this",
".",
"contractAddress",
";",
"//valueRegistrarContractObj.setProvider(web3Provider.currentPro... | Constructor for Value Registrar Contract Interact
@constructor
@augments OpsManagedKlass
@param {String} contractAddress - address where Contract has been deployed | [
"Constructor",
"for",
"Value",
"Registrar",
"Contract",
"Interact"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/value_registrar.js#L37-L45 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/ops_managed.js | function (contractAddress, web3Provider, currContract, defaultGasPrice) {
this.contractAddress = contractAddress;
this.web3Provider = web3Provider;
this.currContract = currContract;
this.defaultGasPrice = defaultGasPrice;
this.currContract.options.address = contractAddress;
//this.currContract.setProvider(w... | javascript | function (contractAddress, web3Provider, currContract, defaultGasPrice) {
this.contractAddress = contractAddress;
this.web3Provider = web3Provider;
this.currContract = currContract;
this.defaultGasPrice = defaultGasPrice;
this.currContract.options.address = contractAddress;
//this.currContract.setProvider(w... | [
"function",
"(",
"contractAddress",
",",
"web3Provider",
",",
"currContract",
",",
"defaultGasPrice",
")",
"{",
"this",
".",
"contractAddress",
"=",
"contractAddress",
";",
"this",
".",
"web3Provider",
"=",
"web3Provider",
";",
"this",
".",
"currContract",
"=",
... | Constructor for Ops Managed Contract
@constructor
@augments OwnedKlass
@param {string} contractAddress - address where Contract has been deployed
@param {string} web3Provider - web3 provider of network where currContract has been deployed
@param {string} currContract - Contract Instance
@param {string} defaultGasPric... | [
"Constructor",
"for",
"Ops",
"Managed",
"Contract"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/ops_managed.js#L30-L38 | train | |
OpenSTFoundation/openst-platform | lib/contract_interact/simple_token.js | function () {
const oThis = this
;
oThis.contractAddress = simpleTokenContractAddr;
simpleTokenContractObj.options.address = oThis.contractAddress;
//simpleTokenContractObj.setProvider(web3Provider.currentProvider);
OpsManagedKlass.call(oThis, oThis.contractAddress, web3Provider, simpleTokenContractObj, V... | javascript | function () {
const oThis = this
;
oThis.contractAddress = simpleTokenContractAddr;
simpleTokenContractObj.options.address = oThis.contractAddress;
//simpleTokenContractObj.setProvider(web3Provider.currentProvider);
OpsManagedKlass.call(oThis, oThis.contractAddress, web3Provider, simpleTokenContractObj, V... | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"oThis",
".",
"contractAddress",
"=",
"simpleTokenContractAddr",
";",
"simpleTokenContractObj",
".",
"options",
".",
"address",
"=",
"oThis",
".",
"contractAddress",
";",
"//simpleTokenContractObj.setPro... | Constructor for SimpleToken Contract Interact
@constructor
@augments OpsManagedKlass | [
"Constructor",
"for",
"SimpleToken",
"Contract",
"Interact"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/contract_interact/simple_token.js#L43-L52 | train | |
OpenSTFoundation/openst-platform | helpers/registration_status.js | function () {
const oThis = this
;
return {
uuid: oThis.uuid,
erc20_address: oThis.erc20Address,
is_proposal_done: oThis.isProposalDone,
is_registered_on_uc: oThis.isRegisteredOnUc,
is_registered_on_vc: oThis.isRegisteredOnVc
}
} | javascript | function () {
const oThis = this
;
return {
uuid: oThis.uuid,
erc20_address: oThis.erc20Address,
is_proposal_done: oThis.isProposalDone,
is_registered_on_uc: oThis.isRegisteredOnUc,
is_registered_on_vc: oThis.isRegisteredOnVc
}
} | [
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"return",
"{",
"uuid",
":",
"oThis",
".",
"uuid",
",",
"erc20_address",
":",
"oThis",
".",
"erc20Address",
",",
"is_proposal_done",
":",
"oThis",
".",
"isProposalDone",
",",
"is_registered_on_uc"... | convert the RegistrationStatus object to an object
@return {object} returns a formatted object of registration status | [
"convert",
"the",
"RegistrationStatus",
"object",
"to",
"an",
"object"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/helpers/registration_status.js#L37-L48 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | function (params) {
const oThis = this;
oThis.btName = params.bt_name; // branded token name
oThis.btSymbol = params.bt_symbol; // branded token symbol
oThis.btConversionFactor = params.bt_conversion_factor; // branded token to OST conversion factor, 1 OST = 10 ACME
oThis.reserveAddress = ''; // Member co... | javascript | function (params) {
const oThis = this;
oThis.btName = params.bt_name; // branded token name
oThis.btSymbol = params.bt_symbol; // branded token symbol
oThis.btConversionFactor = params.bt_conversion_factor; // branded token to OST conversion factor, 1 OST = 10 ACME
oThis.reserveAddress = ''; // Member co... | [
"function",
"(",
"params",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"oThis",
".",
"btName",
"=",
"params",
".",
"bt_name",
";",
"// branded token name",
"oThis",
".",
"btSymbol",
"=",
"params",
".",
"bt_symbol",
";",
"// branded token symbol",
"oThis",
... | Constructor for proposing branded token
@param {object} params - this is params
@param {object} params.bt_symbol - branded token symbol
@param {object} params.bt_name - branded token name
@param {object} params.bt_conversion_factor - branded token conversion factor
@constructor | [
"Constructor",
"for",
"proposing",
"branded",
"token"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L50-L62 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | async function () {
const oThis = this;
// Validate new branded token
logger.step("** Validating branded token");
await oThis._validateBrandedTokenDetails();
// Generate reserve address
logger.step("** Generating reserve address");
var addressRes = await oThis._generateAddress();
oThis... | javascript | async function () {
const oThis = this;
// Validate new branded token
logger.step("** Validating branded token");
await oThis._validateBrandedTokenDetails();
// Generate reserve address
logger.step("** Generating reserve address");
var addressRes = await oThis._generateAddress();
oThis... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"// Validate new branded token",
"logger",
".",
"step",
"(",
"\"** Validating branded token\"",
")",
";",
"await",
"oThis",
".",
"_validateBrandedTokenDetails",
"(",
")",
";",
"// Generate reser... | Start BT proposal | [
"Start",
"BT",
"proposal"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L68-L100 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | async function() {
const oThis = this
;
const addressObj = new generateAddress({chain: 'utility', passphrase: oThis.reservePassphrase})
, addressResponse = await addressObj.perform();
if (addressResponse.isFailure()) {
logger.error("* Reserve address generation failed with error:", addressRe... | javascript | async function() {
const oThis = this
;
const addressObj = new generateAddress({chain: 'utility', passphrase: oThis.reservePassphrase})
, addressResponse = await addressObj.perform();
if (addressResponse.isFailure()) {
logger.error("* Reserve address generation failed with error:", addressRe... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"const",
"addressObj",
"=",
"new",
"generateAddress",
"(",
"{",
"chain",
":",
"'utility'",
",",
"passphrase",
":",
"oThis",
".",
"reservePassphrase",
"}",
")",
",",
"addressResponse",
... | Generate reserve address
@return {promise<result>}
@private | [
"Generate",
"reserve",
"address"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L108-L118 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | async function() {
const oThis = this
;
logger.step("** Starting BT proposal");
logger.info("* Name:", oThis.btName, "Symbol:", oThis.btSymbol, "Conversion Factor:", oThis.btConversionFactor);
const proposeBTObj = new proposeBrandedToken(
{name: oThis.btName, symbol: oThis.btSymbol, conversion... | javascript | async function() {
const oThis = this
;
logger.step("** Starting BT proposal");
logger.info("* Name:", oThis.btName, "Symbol:", oThis.btSymbol, "Conversion Factor:", oThis.btConversionFactor);
const proposeBTObj = new proposeBrandedToken(
{name: oThis.btName, symbol: oThis.btSymbol, conversion... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"logger",
".",
"step",
"(",
"\"** Starting BT proposal\"",
")",
";",
"logger",
".",
"info",
"(",
"\"* Name:\"",
",",
"oThis",
".",
"btName",
",",
"\"Symbol:\"",
",",
"oThis",
".",
"b... | Start the proposal of branded token
@return {promise<result>}
@private | [
"Start",
"the",
"proposal",
"of",
"branded",
"token"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L126-L140 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | function(transaction_hash) {
const oThis = this
, timeInterval = 5000
, proposeSteps = {is_proposal_done: 0, is_registered_on_uc: 0, is_registered_on_vc: 0}
;
return new Promise(function(onResolve, onReject){
logger.step("** Monitoring BT proposal status");
const statusObj = new ge... | javascript | function(transaction_hash) {
const oThis = this
, timeInterval = 5000
, proposeSteps = {is_proposal_done: 0, is_registered_on_uc: 0, is_registered_on_vc: 0}
;
return new Promise(function(onResolve, onReject){
logger.step("** Monitoring BT proposal status");
const statusObj = new ge... | [
"function",
"(",
"transaction_hash",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"timeInterval",
"=",
"5000",
",",
"proposeSteps",
"=",
"{",
"is_proposal_done",
":",
"0",
",",
"is_registered_on_uc",
":",
"0",
",",
"is_registered_on_vc",
":",
"0",
"}",
";",... | Check propose status
@param {string} transaction_hash - BT proposal transaction hash
@return {promise<result>}
@private | [
"Check",
"propose",
"status"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L150-L188 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | async function() {
const oThis = this
, existingBrandedTokens = await oThis._loadBrandedTokenConfig()
;
for (var uuid in existingBrandedTokens) {
var brandedToken = existingBrandedTokens[uuid];
if (oThis.btName.equalsIgnoreCase(brandedToken.Name)) {
logger.error("* Branded token na... | javascript | async function() {
const oThis = this
, existingBrandedTokens = await oThis._loadBrandedTokenConfig()
;
for (var uuid in existingBrandedTokens) {
var brandedToken = existingBrandedTokens[uuid];
if (oThis.btName.equalsIgnoreCase(brandedToken.Name)) {
logger.error("* Branded token na... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"existingBrandedTokens",
"=",
"await",
"oThis",
".",
"_loadBrandedTokenConfig",
"(",
")",
";",
"for",
"(",
"var",
"uuid",
"in",
"existingBrandedTokens",
")",
"{",
"var",
"brandedToken",
... | Check for duplicate branded token
@return {boolean}
@private | [
"Check",
"for",
"duplicate",
"branded",
"token"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L196-L212 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | async function() {
const oThis = this
, existingBrandedTokens = await oThis._loadBrandedTokenConfig()
;
if (existingBrandedTokens[oThis.uuid]) {
logger.error("* Branded token uuid already registered and present in BT config file");
process.exit(1);
}
existingBrandedTokens[oThis.u... | javascript | async function() {
const oThis = this
, existingBrandedTokens = await oThis._loadBrandedTokenConfig()
;
if (existingBrandedTokens[oThis.uuid]) {
logger.error("* Branded token uuid already registered and present in BT config file");
process.exit(1);
}
existingBrandedTokens[oThis.u... | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
",",
"existingBrandedTokens",
"=",
"await",
"oThis",
".",
"_loadBrandedTokenConfig",
"(",
")",
";",
"if",
"(",
"existingBrandedTokens",
"[",
"oThis",
".",
"uuid",
"]",
")",
"{",
"logger",
"... | Update branded token details
@return {promise<object>} - branded tokens list
@private | [
"Update",
"branded",
"token",
"details"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L220-L243 | train | |
OpenSTFoundation/openst-platform | tools/setup/branded_token/register.js | async function() {
const oThis = this
;
await new openSTStorage.TokenBalanceModel({
ddb_service: ddbServiceObj,
auto_scaling: autoScalingServiceObj,
erc20_contract_address: oThis.erc20
}).allocate();
} | javascript | async function() {
const oThis = this
;
await new openSTStorage.TokenBalanceModel({
ddb_service: ddbServiceObj,
auto_scaling: autoScalingServiceObj,
erc20_contract_address: oThis.erc20
}).allocate();
} | [
"async",
"function",
"(",
")",
"{",
"const",
"oThis",
"=",
"this",
";",
"await",
"new",
"openSTStorage",
".",
"TokenBalanceModel",
"(",
"{",
"ddb_service",
":",
"ddbServiceObj",
",",
"auto_scaling",
":",
"autoScalingServiceObj",
",",
"erc20_contract_address",
":",... | Allocate shard to branded token
@return {promise<object>} -
@private | [
"Allocate",
"shard",
"to",
"branded",
"token"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/tools/setup/branded_token/register.js#L251-L260 | train | |
OpenSTFoundation/openst-platform | lib/web3/events/decoder.js | function (address, addressToNameMap) {
const lcAddress = String(address).toLowerCase();
if (!addressToNameMap || !( addressToNameMap[address] || addressToNameMap[lcAddress] )) {
return coreAddresses.getContractNameFor(address);
}
return addressToNameMap[address] || addressToNameMap[lcAddress];
} | javascript | function (address, addressToNameMap) {
const lcAddress = String(address).toLowerCase();
if (!addressToNameMap || !( addressToNameMap[address] || addressToNameMap[lcAddress] )) {
return coreAddresses.getContractNameFor(address);
}
return addressToNameMap[address] || addressToNameMap[lcAddress];
} | [
"function",
"(",
"address",
",",
"addressToNameMap",
")",
"{",
"const",
"lcAddress",
"=",
"String",
"(",
"address",
")",
".",
"toLowerCase",
"(",
")",
";",
"if",
"(",
"!",
"addressToNameMap",
"||",
"!",
"(",
"addressToNameMap",
"[",
"address",
"]",
"||",
... | Get contract name for an particular address
@param {string} address - address of the contract from which the event is raised
@param {object} addressToNameMap - Address to name map
@return {string} - returns the name of the contract from the address - returns
null for contracts which are not recognized | [
"Get",
"contract",
"name",
"for",
"an",
"particular",
"address"
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/lib/web3/events/decoder.js#L126-L132 | train | |
OpenSTFoundation/openst-platform | executables/notification_subscribe.js | subscribe | function subscribe() {
openSTNotification.subscribeEvent.rabbit(
['#'],
{queue: 'openst_platform'},
function (msgContent) {
logger.debug('[RECEIVED]', msgContent, '\n');
}
).catch(function (err) {
logger.error(err);
});
} | javascript | function subscribe() {
openSTNotification.subscribeEvent.rabbit(
['#'],
{queue: 'openst_platform'},
function (msgContent) {
logger.debug('[RECEIVED]', msgContent, '\n');
}
).catch(function (err) {
logger.error(err);
});
} | [
"function",
"subscribe",
"(",
")",
"{",
"openSTNotification",
".",
"subscribeEvent",
".",
"rabbit",
"(",
"[",
"'#'",
"]",
",",
"{",
"queue",
":",
"'openst_platform'",
"}",
",",
"function",
"(",
"msgContent",
")",
"{",
"logger",
".",
"debug",
"(",
"'[RECEIV... | Subscribe to all events of rabbit. | [
"Subscribe",
"to",
"all",
"events",
"of",
"rabbit",
"."
] | 2bcc62c7c7740b5f424fd9b467197aa14a94bb32 | https://github.com/OpenSTFoundation/openst-platform/blob/2bcc62c7c7740b5f424fd9b467197aa14a94bb32/executables/notification_subscribe.js#L15-L25 | train |
enketo/enketo-transformer | src/language.js | parse | function parse( lang, sample ) {
// TODO: this should be refactored
let ianaLang;
const language = {
desc: lang.trim(),
tag: lang.trim(),
src: lang
};
const parts = lang.match( /^([^(]+)\((.*)\)\s*$/ );
if ( parts && parts.length > 2 ) {
language.desc = parts[ 1 ... | javascript | function parse( lang, sample ) {
// TODO: this should be refactored
let ianaLang;
const language = {
desc: lang.trim(),
tag: lang.trim(),
src: lang
};
const parts = lang.match( /^([^(]+)\((.*)\)\s*$/ );
if ( parts && parts.length > 2 ) {
language.desc = parts[ 1 ... | [
"function",
"parse",
"(",
"lang",
",",
"sample",
")",
"{",
"// TODO: this should be refactored",
"let",
"ianaLang",
";",
"const",
"language",
"=",
"{",
"desc",
":",
"lang",
".",
"trim",
"(",
")",
",",
"tag",
":",
"lang",
".",
"trim",
"(",
")",
",",
"sr... | Parses a language string into a language object. Guesses missing properties.
@see http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
@param {string} lang language strings as included in the XForm
@return {{desc: string, tag: string, dir: string, src: string}} language object | [
"Parses",
"a",
"language",
"string",
"into",
"a",
"language",
"object",
".",
"Guesses",
"missing",
"properties",
"."
] | 58f65a71c7695fd12ace32c86b7a0f719cad6159 | https://github.com/enketo/enketo-transformer/blob/58f65a71c7695fd12ace32c86b7a0f719cad6159/src/language.js#L11-L42 | train |
enketo/enketo-transformer | src/language.js | _getLangWithDesc | function _getLangWithDesc( desc ) {
const results = ( desc ) ? tags.search( desc ).filter( _languagesOnly ) : [];
return results[ 0 ] || '';
} | javascript | function _getLangWithDesc( desc ) {
const results = ( desc ) ? tags.search( desc ).filter( _languagesOnly ) : [];
return results[ 0 ] || '';
} | [
"function",
"_getLangWithDesc",
"(",
"desc",
")",
"{",
"const",
"results",
"=",
"(",
"desc",
")",
"?",
"tags",
".",
"search",
"(",
"desc",
")",
".",
"filter",
"(",
"_languagesOnly",
")",
":",
"[",
"]",
";",
"return",
"results",
"[",
"0",
"]",
"||",
... | Performs IANA search to find language object with provided description
@param {string} desc language description
@return {<*>} the first language object result that was found | [
"Performs",
"IANA",
"search",
"to",
"find",
"language",
"object",
"with",
"provided",
"description"
] | 58f65a71c7695fd12ace32c86b7a0f719cad6159 | https://github.com/enketo/enketo-transformer/blob/58f65a71c7695fd12ace32c86b7a0f719cad6159/src/language.js#L50-L53 | train |
enketo/enketo-transformer | src/transformer.js | transform | function transform( survey ) {
let xformDoc;
const xsltParams = survey.includeRelevantMsg ? {
'include-relevant-msg': 1
} : {};
return _parseXml( survey.xform )
.then( doc => {
if ( typeof survey.preprocess === 'function' ) {
doc = survey.preprocess.call( lib... | javascript | function transform( survey ) {
let xformDoc;
const xsltParams = survey.includeRelevantMsg ? {
'include-relevant-msg': 1
} : {};
return _parseXml( survey.xform )
.then( doc => {
if ( typeof survey.preprocess === 'function' ) {
doc = survey.preprocess.call( lib... | [
"function",
"transform",
"(",
"survey",
")",
"{",
"let",
"xformDoc",
";",
"const",
"xsltParams",
"=",
"survey",
".",
"includeRelevantMsg",
"?",
"{",
"'include-relevant-msg'",
":",
"1",
"}",
":",
"{",
"}",
";",
"return",
"_parseXml",
"(",
"survey",
".",
"xf... | Performs XSLT transformation on XForm and process the result.
@param {{xform: string, theme: string}} survey Survey object with at least an xform property
@return {Promise} promise | [
"Performs",
"XSLT",
"transformation",
"on",
"XForm",
"and",
"process",
"the",
"result",
"."
] | 58f65a71c7695fd12ace32c86b7a0f719cad6159 | https://github.com/enketo/enketo-transformer/blob/58f65a71c7695fd12ace32c86b7a0f719cad6159/src/transformer.js#L22-L65 | train |
Subsets and Splits
SQL Console for semeru/code-text-javascript
Retrieves 20,000 non-null code samples labeled as JavaScript, providing a basic overview of the dataset.