How to use the licia.trim function in licia

To help you get started, we’ve selected a few licia examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liriliri / licia / lib / update.js View on Github external
each(comments, function(comment) {
            let lines = trim(comment).split('\n');
            if (trim(lines[0]) !== 'module') return;
            lines.shift();
            each(lines, function(line) {
                let splitterPos = line.indexOf(':');
                let name = trim(line.slice(0, splitterPos));
                let val = trim(line.slice(splitterPos + 1));
                if (name === 'env') {
                    if (val === 'all') {
                        val = ['node', 'browser', 'miniprogram'];
                    } else {
                        val = val.split(/\s+/g);
                    }
                }
                if (name === 'test') {
                    if (val === 'manual') {
                        val = [];
                    } else if (val === 'all') {
github liriliri / licia / lib / update.js View on Github external
return doc.map(str => {
        str = str.split(/\n/);
        const name = str.shift().trim();
        return {
            name,
            content: trim(str.join('\n'))
        };
    });
}
github liriliri / licia / lib / update.js View on Github external
function extractDependencies(data) {
        let dependencies = regDependency.exec(data);
        dependencies = dependencies ? trim(dependencies[1]).split(/\s+/) : [];

        return dependencies;
    }
github liriliri / licia / lib / update.js View on Github external
each(comments, function(comment) {
            let lines = trim(comment).split('\n');
            if (trim(lines[0]) !== 'module') return;
            lines.shift();
            each(lines, function(line) {
                let splitterPos = line.indexOf(':');
                let name = trim(line.slice(0, splitterPos));
                let val = trim(line.slice(splitterPos + 1));
                if (name === 'env') {
                    if (val === 'all') {
                        val = ['node', 'browser', 'miniprogram'];
                    } else {
                        val = val.split(/\s+/g);
                    }
                }
                if (name === 'test') {
                    if (val === 'manual') {
                        val = [];
github liriliri / licia / lib / update.js View on Github external
each(lines, function(line) {
                let splitterPos = line.indexOf(':');
                let name = trim(line.slice(0, splitterPos));
                let val = trim(line.slice(splitterPos + 1));
                if (name === 'env') {
                    if (val === 'all') {
                        val = ['node', 'browser', 'miniprogram'];
                    } else {
                        val = val.split(/\s+/g);
                    }
                }
                if (name === 'test') {
                    if (val === 'manual') {
                        val = [];
                    } else if (val === 'all') {
                        val = ['node', 'browser'];
                    } else {
                        val = [val];
                    }
                }
github liriliri / licia / lib / update.js View on Github external
comments.forEach(comment => {
                comment = trim(comment);
                if (startWith(comment, 'example')) {
                    example = comment.replace(/^example/, '');
                    example = outdentOneSpace(example);
                    example = example.replace(regTsIgnore, '');
                    example = '```javascript\n' + trim(example) + '\n```';
                }
            });
            doc = splitH2(doc);
github liriliri / licia / lib / update.js View on Github external
comments.forEach(comment => {
                comment = trim(comment);
                if (startWith(comment, 'example')) {
                    example = comment.replace(/^example/, '');
                    example = outdentOneSpace(example);
                    example = example.replace(regTsIgnore, '');
                    example = '```javascript\n' + trim(example) + '\n```';
                }
            });
            doc = splitH2(doc);
github liriliri / licia / lib / pack.js View on Github external
function transToCommonjs(data, dependencies, isEs5) {
    data = trim(data);
    data += '\n\nmodule.exports = exports;\n';

    if (!dependencies) return data;

    let requires = '';
    const len = dependencies.length;

    each(dependencies, (val, i) => {
        requires +=
            (isEs5 ? 'var ' : 'const ') + val + " = require('./" + val + "');";

        if (i !== len - 1) requires += '\n';
    });

    if (requires) {
        requires = '\n\n' + requires;