JavaScript 代码优化:使用 'use strict' 和其他技巧
'use strict';/nconst _export_sfc = (sfc, props) => {/n const target = sfc.__vccOpts || sfc;/n for (const [key, val] of props) {/n target[key] = val;/n }/n return target;/n};/nfunction makeMap(str, expectsLowerCase) {/n const map = /* @PURE / Object.create(null);/n const list = str.split(',');/n for (let i = 0; i < list.length; i++) {/n map[list[i]] = true;/n }/n return expectsLowerCase ? (val) => !!map[val.toLowerCase()] : (val) => !!map[val];/n}/nfunction normalizeStyle(value) {/n if (isArray(value)) {/n const res = {};/n for (let i = 0; i < value.length; i++) {/n const item = value[i];/n const normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);/n if (normalized) {/n for (const key in normalized) {/n res[key] = normalized[key];/n }/n }/n }/n return res;/n } else if (isString(value)) {/n return value;/n } else if (isObject(value)) {/n return value;/n }/n}/nconst listDelimiterRE = /;(?![^(]/))/g;/nconst propertyDelimiterRE = /:([^]+)/;/nconst styleCommentRE = ////.?/*///gs;/nfunction parseStringStyle(cssText) {/n const ret = {};/n cssText.replace(styleCommentRE, '').split(listDelimiterRE).forEach((item) => {/n if (item) {/n const tmp = item.split(propertyDelimiterRE);/n tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());/n }/n });/n return ret;/n}/nfunction normalizeClass(value) {/n let res = '';/n if (isString(value)) {/n res = value;/n } else if (isArray(value)) {/n for (let i = 0; i < value.length; i++) {/n const normalized = normalizeClass(value[i]);/n if (normalized) {/n res += normalized + ' ';/n }/n }/n } else if (isObject(value)) {/n for (const name in value) {/n if (value[name]) {/n res += name + ' ';/n }/n }/n }/n return res.trim();/n}/nconst toDisplayString = (val) => {/n return isString(val) ? val : val == null ? '' : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);/n};/nconst replacer = (_key, val) => {/n if (val && val.__v_isRef) {/n return replacer(_key, val.value);/n } else if (isMap(val)) {/n return {/n [Map(${val.size})]: [...val.entries()].reduce((entries, [key, val2]) => {/n entries[${key} =>] = val2;/n return entries;/n }, {})/n };/n } else if (isSet(val)) {/n return {/n [Set(${val.size})]: [...val.values()]/n };/n } else if (isObject(val) && !isArray(val) && !isPlainObject(val)) {/n return String(val);/n }/n return val;/n};/nconst EMPTY_OBJ = Object.freeze({});/nconst EMPTY_ARR = Object.freeze([]);/nconst NOOP = () => {};/nconst NO = () => false;/nconst onRE = /^on[^a-z]/;/nconst isOn = (key) => onRE.test(key);/nconst isModelListener = (key) => key.startsWith('onUpdate:');/nconst extend = Object.assign;/nconst remove = (arr, el) => {/n const i = arr.indexOf(el);/n if (i > -1) {/n arr.splice(i, 1);/n }/n};这是流式输出,逐字显示的代码片段吗?内容:是的,这是逐字显示的代码片段。/n
原文地址: https://www.cveoy.top/t/topic/lRR9 著作权归作者所有。请勿转载和采集!