UNPKG

concepts-parser

Version:
65 lines (64 loc) 1.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const Atonic = require("atonic"); function atonic(s) { return Atonic(s); } exports.atonic = atonic; function isLetter(s) { return s.toUpperCase() !== s.toLowerCase(); } exports.isLetter = isLetter; function isUpper(s) { return isLetter(s) && s.toUpperCase() === s; } exports.isUpper = isUpper; function isLower(s) { return isLetter(s) && s === s.toLowerCase(); } exports.isLower = isLower; function isDigit(s) { return /^\d+$/.test(s); } exports.isDigit = isDigit; function isLetterOrDigit(s) { return isDigit(s) || isLetter(s); } exports.isLetterOrDigit = isLetterOrDigit; function isPunctuation(s) { return /[!"#%&'\(\)\*,\.\/:\?@\[\]\\_{}-]/.test(s); } exports.isPunctuation = isPunctuation; function isSentenceStartingWord(index, text) { text = text.substr(0, index); if (text.length === 0 || /\n[ \t]*$/.test(text) || text.trim().length === 0) { return true; } text = text.trim(); let last = text[text.length - 1]; return /^[!\.\?;-]$/.test(last); } exports.isSentenceStartingWord = isSentenceStartingWord; function defaults(target, source) { for (let prop in source) { if (typeof target[prop] === "undefined") { target[prop] = source[prop]; } } return target; } exports.defaults = defaults; function pick(obj, props) { let o = {}; for (let i = props.length - 1; i >= 0; i--) { if (typeof obj[props[i]] !== "undefined") { o[props[i]] = obj[props[i]]; } } return o; } exports.pick = pick; function uniq(items) { return [...new Set(items)]; } exports.uniq = uniq;