add
This commit is contained in:
14
pkg/axios/bin/helpers/colorize.js
Normal file
14
pkg/axios/bin/helpers/colorize.js
Normal file
@ -0,0 +1,14 @@
|
||||
import chalk from 'chalk';
|
||||
|
||||
export const colorize = (...colors)=> {
|
||||
if(!colors.length) {
|
||||
colors = ['green', 'cyan', 'magenta', 'blue', 'yellow', 'red'];
|
||||
}
|
||||
|
||||
const colorsCount = colors.length;
|
||||
|
||||
return (strings, ...values) => {
|
||||
const {length} = values;
|
||||
return strings.map((str, i) => i < length ? str + chalk[colors[i%colorsCount]].bold(values[i]) : str).join('');
|
||||
}
|
||||
}
|
12
pkg/axios/bin/helpers/parser.js
Normal file
12
pkg/axios/bin/helpers/parser.js
Normal file
@ -0,0 +1,12 @@
|
||||
export const matchAll = (text, regexp, cb) => {
|
||||
let match;
|
||||
while((match = regexp.exec(text))) {
|
||||
cb(match);
|
||||
}
|
||||
}
|
||||
|
||||
export const parseSection = (body, name, cb) => {
|
||||
matchAll(body, new RegExp(`^(#+)\\s+${name}?(.*?)^\\1\\s+\\w+`, 'gims'), cb);
|
||||
}
|
||||
|
||||
export const parseVersion = (rawVersion) => /^v?(\d+).(\d+).(\d+)/.exec(rawVersion);
|
Reference in New Issue
Block a user