How to use createCharCode method in wpt

Best JavaScript code snippet using wpt

fonts.js

Source:fonts.js Github

copy

Full Screen

...1885 }1886 }1887 return charCodes;1888 }1889 function createCharCode(charCodeToGlyphId, glyphId) {1890 for (var charCode in charCodeToGlyphId) {1891 if (glyphId === charCodeToGlyphId[charCode]) {1892 return charCode | 0;1893 }1894 }1895 newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;1896 return newMapping.nextAvailableFontCharCode++;1897 }1898 var seacs = font.seacs;1899 if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {1900 var matrix = properties.fontMatrix || _util.FONT_IDENTITY_MATRIX;1901 var charset = font.getCharset();1902 var seacMap = Object.create(null);1903 for (var glyphId in seacs) {1904 glyphId |= 0;1905 var seac = seacs[glyphId];1906 var baseGlyphName = _encodings.StandardEncoding[seac[2]];1907 var accentGlyphName = _encodings.StandardEncoding[seac[3]];1908 var baseGlyphId = charset.indexOf(baseGlyphName);1909 var accentGlyphId = charset.indexOf(accentGlyphName);1910 if (baseGlyphId < 0 || accentGlyphId < 0) {1911 continue;1912 }1913 var accentOffset = {1914 x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],1915 y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]1916 };1917 var charCodes = getCharCodes(mapping, glyphId);1918 if (!charCodes) {1919 continue;1920 }1921 for (var i = 0, ii = charCodes.length; i < ii; i++) {1922 var charCode = charCodes[i];1923 var charCodeToGlyphId = newMapping.charCodeToGlyphId;1924 var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);1925 var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);1926 seacMap[charCode] = {1927 baseFontCharCode: baseFontCharCode,1928 accentFontCharCode: accentFontCharCode,1929 accentOffset: accentOffset1930 };1931 }1932 }1933 properties.seacMap = seacMap;1934 }1935 var unitsPerEm = 1 / (properties.fontMatrix || _util.FONT_IDENTITY_MATRIX)[0];1936 var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');1937 builder.addTable('CFF ', font.data);1938 builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));1939 builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import Vue from 'vue';2const vm = new Vue();3/**4 * @param {Array} list5 * @param {Function} f6 * @return {*}7 */8export function find (list, f) {9 return list.filter(f)[0];10}11/**12 * forEach for object13 */14export function forEachValue (obj, fn) {15 Object.keys(obj).forEach(key => fn(obj[key], key));16}17export function isObject (obj) {18 return obj !== null && typeof obj === 'object';19}20// 数组去重 元素的键21export function uniqueFunc (arr, uniId) {22 const res = new Map();23 return arr.filter((item) => !res.has(item[uniId]) && res.set(item[uniId], 1));24}25export function isPromise (val) {26 return val && typeof val.then === 'function';27}28export function assert (condition, msg) {29 if (!condition) throw new Error(`[vuex] ${msg}`);30}31export function partial (fn, arg) {32 return function () {33 return fn(arg);34 };35}36export const queryToObj = (key) => {37 let url = window.location.search; // 获取当前url38 if (url) {39 let cs = url.split('?')[1]; // 获取?之后的参数字符串40 let csArr = cs.split('&'); // 参数字符串分割为数组41 const obj = {};42 for (let i = 0; i < csArr.length; i++) { // 遍历数组,拿到json对象43 obj[csArr[i].split('=')[0]] = csArr[i].split('=')[1];44 }45 return obj[key];46 }47 return null;48};49// 格式化链接参数50export const getQueryObject = (url) => {51 const search = url.substring(url.lastIndexOf('?') + 1);52 const obj = {};53 const reg = /([^?&=]+)=([^?&=]*)/g;54 search.replace(reg, (rs, $1, $2) => {55 const name = decodeURIComponent($1);56 let val = decodeURIComponent($2);57 val = String(val);58 obj[name] = val;59 return rs;60 });61 return obj;62};63export const objToQuery = (obj) => {64 let str = '';65 for (let key in obj) {66 if (str !== '') {67 str += '&';68 }69 if (key) {70 str += key + '=' + encodeURIComponent(obj[key]);71 }72 }73 return str;74};75let pngMagic = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];76let jpegJfif = [0x4a, 0x46, 0x49, 0x46];77let jpegExif = [0x45, 0x78, 0x69, 0x66];78let jpegMagic = [0xFF, 0xD8, 0xFF, 0xE0];79let gifMagic0 = [0x47, 0x49, 0x46, 0x38, 0x37, 0x61];80let getGifMagic1 = [0x47, 0x49, 0x46, 0x38, 0x39, 0x61];81function arraycopy (src, index, dist, distIndex, size) {82 for (let i = 0; i < size; i++) {83 dist[distIndex + i] = src[index + i];84 }85}86function arrayEquals (arr1, arr2) {87 if (arr1 === 'undefined' || arr2 === 'undefined') {88 return false;89 }90 if (arr1 instanceof Array && arr2 instanceof Array) {91 if (arr1.length !== arr2.length) {92 return false;93 }94 for (let i = 0; i < arr1.length; i++) {95 if (arr1[i] !== arr2[i]) {96 return false;97 }98 }99 return true;100 }101 return false;102}103export const isImage = (buf) => {104 if (buf === null || buf === 'undefined' || buf.length < 8) {105 return null;106 }107 let bytes = [];108 arraycopy(buf, 0, bytes, 0, 6);109 if (isGif(bytes)) {110 return 'image/gif';111 }112 bytes = [];113 arraycopy(buf, 6, bytes, 0, 4);114 if (isJpeg(bytes)) {115 return 'image/jpeg';116 }117 bytes = [];118 arraycopy(buf, 0, bytes, 0, 8);119 if (isPng(bytes)) {120 return 'image/png';121 }122 return null;123};124/**125 * @param data first 6 bytes of file126 * @return gif image file true,other false127 */128function isGif (data) {129 return arrayEquals(data, gifMagic0) || arrayEquals(data, getGifMagic1);130}131/**132 * @param data first 4 bytes of file133 * @return jpeg image file true,other false134 */135function isJpeg (data) {136 return arrayEquals(data, jpegMagic) || arrayEquals(data, jpegJfif) || arrayEquals(data, jpegExif);137}138/**139 * @param data first 8 bytes of file140 * @return png image file true,other false141 */142function isPng (data) {143 return arrayEquals(data, pngMagic);144}145/**146 * 导出147 *148 * @param {Object} 后端返回的整个response149 */150export function exportExcel (oRequest) {151 const fileName = decodeURIComponent(152 oRequest.headers['content-disposition']153 ).split('=')[1];154 const blob = new Blob([oRequest.data], { type: 'application/vnd.ms-excel' });155 const elink = document.createElement('a');156 elink.download = fileName;157 elink.style.display = 'none';158 elink.href = URL.createObjectURL(blob);159 document.body.appendChild(elink);160 elink.click();161 URL.revokeObjectURL(elink.href); // 释放URL 对象162 document.body.removeChild(elink);163}164/**165 * 下载文件流166 * @param blob 文件流167 * @param filename 文件名字168 * @param type 文件类型 "application/excel"169 */170export function downloadStreamBlob (blob, filename, type = 'application/excel') {171 // 防止重复添加a链接172 const oOldA = document.getElementById('downloadstream');173 if (oOldA) {174 document.body.removeChild(oOldA);175 }176 // https://stackoverflow.com/questions/20310688/blob-download-is-not-working-in-ie177 if (window.navigator && window.navigator.msSaveOrOpenBlob) {178 window.navigator.msSaveBlob(blob, filename);179 } else {180 // let filename = "设备导出{0}.xlsx".format(vpms.core.date.format("yyyyMMddhhmmss"));181 const oAElement = document.createElement('a');182 oAElement.setAttribute('id', 'downloadstream');183 let binaryData = [];184 binaryData.push(blob);185 const URL = window.URL || window['webkitURL']; // 兼容处理186 const url = URL.createObjectURL(new Blob(binaryData, { type }));187 oAElement.href = url;188 oAElement.download = filename;189 oAElement.click();190 URL.revokeObjectURL(url);191 }192}193// 打开url下载文件194export function downloadByUrl (url, fileName) {195 var downloadURL = url;196 let xhr = new XMLHttpRequest();197 xhr.open('GET', downloadURL, true);198 xhr.responseType = 'arraybuffer';199 xhr.onload = function () {200 if (this.status === 200) {201 let blob = new Blob([this.response], { type: 'application/octet-stream"' });202 if (typeof window.navigator.msSaveBlob !== 'undefined') {203 window.navigator.msSaveBlob(blob, fileName);204 } else {205 let URL = window.URL || window.webkitURL;206 let objectUrl = URL.createObjectURL(blob);207 if (fileName) {208 var a = document.createElement('a');209 if (typeof a.download === 'undefined') {210 window.location = objectUrl;211 } else {212 a.href = objectUrl;213 a.download = fileName;214 document.body.appendChild(a);215 a.click();216 a.remove();217 }218 } else {219 window.location = objectUrl;220 }221 }222 }223 };224 xhr.send();225}226// 导出txt文件227export function exportRaw (fileName, data) {228 // Window.URL 属性返回一个对象,它提供了用于创建和管理对象URLs的静态方法。它也可以作为一个构造函数被调用来构造 URL 对象。229 const urlObject = window.URL || window.webkitURL || window;230 // Blob 对象表示一个不可变、原始数据的类文件对象。231 const exportBlob = new Blob([data]);232 // 创建一个具有指定的命名空间URI和限定名称的元素。 createElementNS() 方法创建带有命名空间的元素节点。该方法返回 Element 对象。233 const saveLink = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');234 // URL.createObjectURL() 静态方法会创建一个 DOMString,其中包含一个表示参数中给出的对象的URL。235 // 这个 URL 的生命周期和创建它的窗口中的 document 绑定。这个新的URL 对象表示指定的 File 对象或 Blob 对象。236 saveLink.href = urlObject.createObjectURL(exportBlob);237 // HTMLAnchorElement.download 属性是一个 DOMString ,表明链接的资源将被下载,而不是显示在浏览器中。238 // HTMLAnchorElement 接口表示超链接元素,并提供一些特别的属性和方法(除了那些继承自普通 HTMLElement对象接口的之外)以用于操作这些元素的布局和显示。239 // DOMString 是一个UTF-16字符串。由于JavaScript已经使用了这样的字符串,所以DOMString 直接映射到 一个String。就是一个普通的字符串240 saveLink.download = fileName;241 // 模拟点击事件242 saveLink.click();243}244/**245 * 复制文本到粘246 * 参考:https://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript247 * @param text 复制的文本248 */249export function fnPureCopyTextToClipboard (text, sucessMessage) {250 let textArea = document.createElement('textarea');251 textArea.style.position = 'fixed';252 textArea.style.top = 0;253 textArea.style.left = 0;254 textArea.style.width = '2em';255 textArea.style.height = '2em';256 textArea.style.padding = 0;257 textArea.style.border = 'none';258 textArea.style.outline = 'none';259 textArea.style.boxShadow = 'none';260 textArea.style.background = 'transparent';261 textArea.value = text;262 document.body.appendChild(textArea);263 textArea.select();264 try {265 let successful = document.execCommand('copy');266 let msg = successful ? 'successful' : 'unsuccessful';267 if (msg === 'successful') {268 if (sucessMessage) {269 vm.$message.success(sucessMessage);270 } else {271 vm.$message.success('复制成功');272 }273 } else {274 window.prompt('复制: Ctrl+C ', text);275 }276 } catch (err) {277 window.prompt('复制: Ctrl+C ', text);278 }279 document.body.removeChild(textArea);280}281/**282 * 数字转为中文283 */284export function fnPureToChinesNum (Num) {285 for (var i = Num.length - 1; i >= 0; i--) {286 Num = Num.replace(',', '');// 替换Num中的“,”287 Num = Num.replace(' ', '');// 替换Num中的空格288 }289 if (isNaN(Num)) { // 验证输入的字符是否为数字290 // alert("请检查小写金额是否正确");291 return;292 }293 // 字符处理完毕后开始转换,采用前后两部分分别转换294 var part = String(Num).split('.');295 var newchar = '';296 // 小数点前进行转化297 for (let i = part[0].length - 1; i >= 0; i--) {298 if (part[0].length > 10) {299 // alert("位数过大,无法计算");300 return '';301 }// 若数量超过拾亿单位,提示302 var tmpnewchar = '';303 var perchar = part[0].charAt(i);304 switch (perchar) {305 case '0': tmpnewchar = '零' + tmpnewchar; break;306 case '1': tmpnewchar = '一' + tmpnewchar; break;307 case '2': tmpnewchar = '二' + tmpnewchar; break;308 case '3': tmpnewchar = '三' + tmpnewchar; break;309 case '4': tmpnewchar = '四' + tmpnewchar; break;310 case '5': tmpnewchar = '五' + tmpnewchar; break;311 case '6': tmpnewchar = '六' + tmpnewchar; break;312 case '7': tmpnewchar = '七' + tmpnewchar; break;313 case '8': tmpnewchar = '八' + tmpnewchar; break;314 case '9': tmpnewchar = '九' + tmpnewchar; break;315 }316 switch (part[0].length - i - 1) {317 case 0: break;318 case 1: if (perchar !== 0) tmpnewchar = tmpnewchar + '十'; break;319 case 2: if (perchar !== 0) tmpnewchar = tmpnewchar + '百'; break;320 case 3: if (perchar !== 0) tmpnewchar = tmpnewchar + '千'; break;321 case 4: tmpnewchar = tmpnewchar + '万'; break;322 case 5: if (perchar !== 0) tmpnewchar = tmpnewchar + '十'; break;323 case 6: if (perchar !== 0) tmpnewchar = tmpnewchar + '百'; break;324 case 7: if (perchar !== 0) tmpnewchar = tmpnewchar + '千'; break;325 case 8: tmpnewchar = tmpnewchar + '亿'; break;326 case 9: tmpnewchar = tmpnewchar + '十'; break;327 }328 newchar = tmpnewchar + newchar;329 }330 // 替换所有无用汉字,直到没有此类无用的数字为止331 while (newchar.search('零零') !== -1 || newchar.search('零亿') !== -1 || newchar.search('亿万') !== -1 || newchar.search('零万') !== -1) {332 newchar = newchar.replace('零亿', '亿');333 newchar = newchar.replace('亿万', '亿');334 newchar = newchar.replace('零万', '万');335 newchar = newchar.replace('零零', '零');336 }337 // 替换以“一十”开头的,为“十”338 if (newchar.indexOf('一十') === 0) {339 newchar = newchar.substr(1);340 }341 // 替换以“零”结尾的,为“”342 if (newchar.lastIndexOf('零') === newchar.length - 1) {343 newchar = newchar.substr(0, newchar.length - 1);344 }345 return newchar;346}347// 隐藏电话号码中间4位348export function hideTel (mobile) {349 var reg = new RegExp('(\\d{3})(\\d{4})(\\d{4})');350 mobile = mobile.toString();351 var tel = mobile.replace(reg, '$1****$3');352 return tel;353}354/*355 * description: 防抖函数356 * param fnName {String} 函数名357 * param wait {Number} 延迟时间358 * return: 处理后的执行函数359 */360export function debounce (fnName, wait) {361 let timeout = null;362 return function () {363 let context = this;364 let args = arguments;365 if (timeout) clearTimeout(timeout);366 timeout = setTimeout(() => {367 this[fnName].apply(context, args);368 }, wait);369 };370}371// 字段名称 下划线转换驼峰372export function fieldToHump (name) {373 return name.replace(/_(\w)/g, function (all, letter) {374 return letter.toUpperCase();375 });376}377// 字段名称 驼峰转换下划线378export function fieldToLine (name) {379 return name.replace(/([A-Z])/g, '_$1').toLowerCase();380}381// 16进制颜色值转换成rgb382export const hexToRgbArr = (hex) => {383 return [parseInt('0x' + hex.slice(1, 3)), parseInt('0x' + hex.slice(3, 5)), parseInt('0x' + hex.slice(5, 7))];384};385// 动态添加脚本386export function loadScript (url, callback) {387 const script = document.createElement('script');388 script.type = 'text/javascript';389 if (script.readyState) { // IE390 script.onreadystatechange = function () {391 if (script.readyState === 'loaded' || script.readyState === 'complete') {392 script.onreadystatechange = null;393 callback && callback();394 }395 };396 } else { // Others397 script.onload = function () {398 callback && callback();399 };400 }401 script.src = url;402 document.body.appendChild(script);403}404// 输出A-Z 26个大写字母405export function createCharCode () {406 const code = [];407 for (let i = 0; i < 26; i++) {408 code.push(String.fromCharCode(65 + i));409 }410 return code;411}412// 千分位分隔符 1000 -> 1,000413export function formatNumOfThousands (num) {414 let reg = /\d{1,3}(?=(\d{3})+$)/g;415 return (num + '').replace(reg, '$&,');...

Full Screen

Full Screen

exercise_5.js

Source:exercise_5.js Github

copy

Full Screen

1/*2substring is a prototype method on the constructor string3create is a static method on the constructor object4createCharCode is a static method on the constructor string5slice is a prototype method on the constructors array and string6toString is a prototype method on all four constructors object, array, number and string...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1wp.texturize.createCharCode('&#8217;', "'");2wp.texturize.createCharCode('&#8220;', '"');3wp.texturize.createCharCode('&#8221;', '"');4wp.texturize.createCharCode('&#8211;', '-');5wp.texturize.createCharCode('&#8212;', '--');6wp.texturize.createCharCode('&#8230;', '...');7wp.texturize.createCharCode('&#8242;', "'");8wp.texturize.createCharCode('&#8243;', '"');9wp.texturize.createCharCode('&#8216;', "'");10wp.texturize.createCharCode('&#8217;', "'");11wp.texturize.createCharCode('&#8220;', '"');12wp.texturize.createCharCode('&#8221;', '"');13wp.texturize.createCharCode('&#8211;', '-');14wp.texturize.createCharCode('&#8212;', '--');15wp.texturize.createCharCode('&#8230;', '...');16wp.texturize.createCharCode('&#8242;', "'");17wp.texturize.createCharCode('&#8243;', '"');18wp.texturize.createCharCode('&#8216;', "'");19wp.texturize.createCharCode('&#8217;', "'");20wp.texturize.createCharCode('&#8220;', '"');21wp.texturize.createCharCode('&#8221;', '"');22wp.texturize.createCharCode('&#8211;', '-');23wp.texturize.createCharCode('&#8212;', '--');24wp.texturize.createCharCode('&#8230;', '...');25wp.texturize.createCharCode('&#8242;', "'");26wp.texturize.createCharCode('&#8243;', '"');27wp.texturize.createCharCode('&#8216;', "'");28wp.texturize.createCharCode('&#8217;', "'");29wp.texturize.createCharCode('&#8220;', '"');30wp.texturize.createCharCode('&#8221;', '"');31wp.texturize.createCharCode('&#8211;', '-');32wp.texturize.createCharCode('&#8212;', '--');33wp.texturize.createCharCode('&#8230;', '...');34wp.texturize.createCharCode('&#8242;', "'");35wp.texturize.createCharCode('&#8243;', '"');36wp.texturize.createCharCode('&#8216;', "'");37wp.texturize.createCharCode('&#8217;', "'");38wp.texturize.createCharCode('&#8220;', '"');39wp.texturize.createCharCode('&#8221;', '"');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var wpt = new WebPageTest('www.webpagetest.org');3var options = {4 videoParams: {5 }6};7wpt.runTest(options, function(err, data) {8 if (err) return console.log(err);9 console.log(data);10});11var wpt = require('wpt');12var wpt = new WebPageTest('www.webpagetest.org');13var options = {14};15wpt.getTestStatus(options, function(err, data) {16 if (err) return console.log(err);17 console.log(data);18});19var wpt = require('wpt');20var wpt = new WebPageTest('www.webpagetest.org');21var options = {22};23wpt.getTestResults(options, function(err, data) {24 if (err) return console.log(err);25 console.log(data);26});27var wpt = require('wpt');28var wpt = new WebPageTest('www.webpagetest.org');29wpt.getLocations(function(err, data) {30 if (err) return console.log(err);31 console.log(data);32});33var wpt = require('wpt');34var wpt = new WebPageTest('www.webpagetest.org');35wpt.getTesters(function(err, data) {36 if (err) return console.log(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var editor = CKEDITOR.replace('editor1', {2 wptextpattern: {3 {start: '*', end: '*', format: 'italic'},4 {start: '_', end: '_', format: 'underline'},5 {start: '~', end: '~', format: 'strikethrough'},6 {start: '#', format: 'h1'},7 {start: '##', format: 'h2'},8 {start: '###', format: 'h3'},9 {start: '####', format: 'h4'},10 {start: '#####', format: 'h5'},11 {start: '######', format: 'h6'},12 {start: '1. ', cmd: 'InsertOrderedList'},13 {start: '* ', cmd: 'InsertUnorderedList'},14 {start: '- ', cmd: 'InsertUnorderedList'}15 }16});

Full Screen

Using AI Code Generation

copy

Full Screen

1const wptextencoder = require("wptextencoder");2const encoder = new wptextencoder.TextEncoder();3const str = "Hello World";4const arr = encoder.encode(str);5console.log(arr);6const wptextdecoder = require("wptextdecoder");7const decoder = new wptextdecoder.TextDecoder();8const arr = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100];9const str = decoder.decode(arr);10console.log(str);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptextpattern = require('wptextpattern');2var text = "this is a test";3var pattern = "test";4var offset = 10;5console.log(wptextpattern.createCharCode(pattern, text, offset));6MIT © [Ankit Kumar](

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful