Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private drawSinglePlugin = ( p: TestScriptPluginData ): void => {
const format = " - %-12s: %s"; // util.format does not support padding :(
this.write( 'Plugin ' + chalk.yellow( p.name ) );
this.write( sprintf( format, 'version', p.version ) );
this.write( sprintf( format, 'description', p.description ) );
this.write( sprintf( format, 'targets', p.targets.join( ', ' ) ) );
const authors = p.authors.map( ( a, idx ) => 0 === idx ? a : sprintf( '%-17s %s', '', a ) );
this.write( sprintf( format, 'authors', authors.join( '\n') ) );
this.write( sprintf( format, 'fake', p.isFake ? 'yes': 'no' ) );
this.write( sprintf( format, 'file', p.file ) );
this.write( sprintf( format, 'class', p.class ) );
};
function postProcess(_text, namedValues, params, count) {
let text = _text;
// test for parsable interval string
if (/\|/.test(text)) {
text = parsePluralInterval(text, count);
}
// replace the counter
if (typeof count == 'number') {
text = vsprintf(text, [parseInt(count, 10)]);
}
// if the text string contains {{Mustache}} patterns we render it as a mini tempalate
if (/\{\{.*\}\}/.test(text)) {
text = Mustache.render(text, namedValues);
}
// if we have extra arguments with values to get replaced,
// an additional substition injects those strings afterwards
if (/%/.test(text) && params.length) {
text = vsprintf(text, params);
}
return text;
}
}
// replace the counter
if (typeof count == 'number') {
text = vsprintf(text, [parseInt(count, 10)]);
}
// if the text string contains {{Mustache}} patterns we render it as a mini tempalate
if (/\{\{.*\}\}/.test(text)) {
text = Mustache.render(text, namedValues);
}
// if we have extra arguments with values to get replaced,
// an additional substition injects those strings afterwards
if (/%/.test(text) && params.length) {
text = vsprintf(text, params);
}
return text;
}
var postProcess = function(msg, namedValues, args, count) {
// test for parsable interval string
if ((/\|/).test(msg)) {
msg = parsePluralInterval(msg, count);
}
// replace the counter
if (typeof count === 'number') {
msg = vsprintf(msg, [parseInt(count, 10)]);
}
// if the msg string contains {{Mustache}} patterns we render it as a mini tempalate
if ((/{{.*}}/).test(msg)) {
msg = Mustache.render(msg, namedValues);
}
// if we have extra arguments with values to get replaced,
// an additional substition injects those strings afterwards
if ((/%/).test(msg) && args && args.length > 0) {
msg = vsprintf(msg, args);
}
return msg;
};
if (rev) this.logger().debug(sprintf('RevisionService::collectRevisions: Saved revision %s (old note)', rev.id));
}
const rev = await this.createNoteRevision_(note);
if (rev) this.logger().debug(sprintf('RevisionService::collectRevisions: Saved revision %s (Last rev was more than %d ms ago)', rev.id, Setting.value('revisionService.intervalBetweenRevisions')));
doneNoteIds.push(noteId);
this.isOldNotesCache_[noteId] = false;
}
}
if (change.type === ItemChange.TYPE_DELETE && !!change.before_change_item) {
const note = JSON.parse(change.before_change_item);
const revExists = await Revision.revisionExists(BaseModel.TYPE_NOTE, note.id, note.updated_time);
if (!revExists) {
const rev = await this.createNoteRevision_(note);
if (rev) this.logger().debug(sprintf('RevisionService::collectRevisions: Saved revision %s (for deleted note)', rev.id));
}
doneNoteIds.push(noteId);
}
Setting.setValue('revisionService.lastProcessedChangeId', change.id);
}
}
} catch (error) {
if (error.code === 'revision_encrypted') {
// One or more revisions are encrypted - stop processing for now
// and these revisions will be processed next time the revision
// collector runs.
this.logger().info('RevisionService::collectRevisions: One or more revision was encrypted. Processing was stopped but will resume later when the revision is decrypted.', error);
} else {
this.logger().error('RevisionService::collectRevisions:', error);
}
if (Object.is(x, -0))
zero = "-" + zero;
return to_luastring(zero);
} else {
let buff = "";
let fe = frexp(x); /* 'x' fraction and exponent */
let m = fe[0];
let e = fe[1];
if (m < 0) { /* is number negative? */
buff += '-'; /* add signal */
m = -m; /* make it positive */
}
buff += "0x"; /* add "0x" */
buff += (m * (1<
humanSize: function(bytes) {
const isNumber = !isNaN(parseFloat(bytes)) && isFinite(bytes);
if (!isNumber) {
return '';
}
// Special case small numbers (including 0), because they're exact.
if (bytes < 1000) {
return sprintf.sprintf('%d', bytes);
}
let index = Math.floor(that.getBaseLog(bytes, 1000));
index = Math.min(that.units.length - 1, index);
return sprintf.sprintf('%.1f %s', bytes / Math.pow(1000, index), that.units[index]);
}
});
function formatForReact(formatString: string, args: FormatArg[]) {
const nodes: React.ReactNodeArray = [];
let cursor = 0;
// always re-parse, do not cache, because we change the match
sprintf.parse(formatString).forEach((match: any, idx: number) => {
if (isString(match)) {
nodes.push(match);
return;
}
let arg: FormatArg = null;
if (match[2]) {
arg = (args[0] as ComponentMap)[match[2][0]];
} else if (match[1]) {
arg = args[parseInt(match[1], 10) - 1];
} else {
arg = args[cursor++];
}
// this points to a react element!
function formatForReact(formatString, args) {
let rv = [];
let cursor = 0;
// always re-parse, do not cache, because we change the match
sprintf.parse(formatString).forEach((match, idx) => {
if (typeof match === 'string') {
rv.push(match);
} else {
let arg = null;
if (match[2]) {
arg = args[0][match[2][0]];
} else if (match[1]) {
arg = args[parseInt(match[1], 10) - 1];
} else {
arg = args[cursor++];
}
// this points to a react element!
if (React.isValidElement(arg)) {
rv.push(React.cloneElement(arg, {key: idx}));
// not a react element, fuck around with it so that sprintf.format
function formatForReact(formatString, args) {
const rv = [];
let cursor = 0;
// always re-parse, do not cache, because we change the match
sprintf.parse(formatString).forEach((match, idx) => {
if (_.isString(match)) {
rv.push(match);
} else {
let arg = null;
if (match[2]) {
arg = args[0][match[2][0]];
} else if (match[1]) {
arg = args[parseInt(match[1], 10) - 1];
} else {
arg = args[cursor++];
}
// this points to a react element!
if (React.isValidElement(arg)) {
rv.push(React.cloneElement(arg, {key: idx}));
// not a react element, fuck around with it so that sprintf.format