Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
function formatForReact(formatString, args) {
const rv = [];
let cursor = 0;
sprintf.parse(formatString).forEach((match, idx) => {
const cpoyMatch = match;
let copyIdx = 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++];
}
if (React.isValidElement(arg)) {
rv.push(React.cloneElement(arg, { key: idx }));
} else {