1
0
This commit is contained in:
2024-03-23 20:25:41 +09:00
parent da958c6f02
commit 15ad5fe9e7
63 changed files with 43634 additions and 0 deletions

View 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('');
}
}

View 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);