/** * タイトルが空文字列の場合にtrueを返す * @returns {boolean} */ isEmptyTitle() { return this.title.length === 0; }
init(text = '') { this.text = this.clearText(text); this.length = this.text.length; this.position = 0; this.next = []; }
req.on('data', function(chunk) { result = result ? Buffer.concat([result, chunk]) : chunk; if (result.length > MAX_OBJECT_SIZE) { req.removeAllListeners('data'); callback(new Error('The file size can not exceed 6m.')); } });
function getNameFromTypes(e) { var type = util.findArray(e.dataTransfer.types, function(type) { if (type.indexOf(NAME_PREFIX) === 0) { return true; } }); return type && type.substring(NAME_PREFIX.length); }
const processRexExp = value => { const re = new RegExp(value) const str = re.toString() return '_' + slugify(str.substr(2, str.length - 4)) }
runner(process.argv.slice(2), { templates: defaultTemplates, cwd: process.cwd(), logger: new Logger(console.log.bind(console)), debug: !!process.env.DEBUG, exec: (action, body) => { const opts = body && body.length > 0 ? { input: body } : {} return require('execa').command(action, { ...opts, shell: true }) }, createPrompter: () => require('enquirer'), }).then(({ success }) => process.exit(success ? 0 : 1))
componentDidUpdate() { if (this.props.show && this.state.name.length === 0) { this.els.name.focus(); } }
function writeFiles(directory, files) { Object.keys(files) .reduce((dirs, pathname) => { // Makes sure templates work with new directory names let writePath = pathname; let unused = `${unusedFunctionDir}/`; if (pathname.substr(0, unused.length) === unused) { writePath = `${functionDir}/${pathname.substr(unused.length)}`; } return writeFile(directory, writePath, files[pathname], dirs); }, {}); }
/** * @description On listening event. * @example * xiaomi.listening(); */ function listening() { this.socket.addMembership(MULTICAST_ADDRESS); const payload = '{"cmd": "whois"}'; this.socket.send(payload, 0, payload.length, DISCOVERY_PORT, MULTICAST_ADDRESS); }
const subtractLight = (color, amount) => { const cc = parseInt(color, 16) - amount; let c = cc < 0 ? 0 : cc; c = c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`; return c; }
delete() { let value = this.value || ''; this.value = value ? value.slice(0, -1) : ''; this.cursor = value.length; this.render(); }
/** * Indicates if a string contains Hiragana or Katakana * @param {String} str Input string. */ hasKana(str) { for (let i = 0; i < str.length; i += 1) { if (this.isKanaChar(str[i])) { return true; } } return false; }
function guidFor(str) { const hash = fnv1a(str).toString(); let slug = slugify(sanitize(str)); // Max the slug at 100 char slug = slug.substring(0, 100 - hash.length - 1); return `${slug}_${hash}`; }