一:JavaScript的RFC兼容UUID生成器(uuid.js)
功能:UUID.js-JavaScript的RFC兼容UUID生成器
// Create a version 4 (random number-based) UUID object var objV4 = UUID.genV4(); // Create a version 1 (time-based) UUID object var objV1 = UUID.genV1(); // Create a UUID object from a hexadecimal string var uuid = UUID.parse("a0e0f130-8c21-11df-92d9-95795a3bcd40"); // Get string representations of a UUID object console.log(uuid.toString()); // "a0e0f130-8c21-11df-92d9-95795a3bcd40" console.log(uuid.hexString); // "a0e0f130-8c21-11df-92d9-95795a3bcd40" console.log(uuid.hexNoDelim); // "a0e0f1308c2111df92d995795a3bcd40" console.log(uuid.bitString); // "101000001110000 ... 1100110101000000" console.log(uuid.urn); // "urn:uuid:a0e0f130-8c21-11df-92d9-95795a3bcd40" // Compare UUID objects console.log(objV4.equals(objV1)); // false // Get UUID version numbers console.log(objV4.version); // 4 console.log(objV1.version); // 1 // Get internal field values in 3 different forms via 2 different accessors console.log(uuid.intFields.timeLow); // 2699096368 console.log(uuid.bitFields.timeMid); // "1000110000100001" console.log(uuid.hexFields.timeHiAndVersion); // "11df" console.log(uuid.intFields.clockSeqHiAndReserved); // 146 console.log(uuid.bitFields.clockSeqLow); // "11011001" console.log(uuid.hexFields.node); // "95795a3bcd40" console.log(uuid.intFields[0]); // 2699096368 console.log(uuid.bitFields[1]); // "1000110000100001" console.log(uuid.hexFields[2]); // "11df" console.log(uuid.intFields[3]); // 146 console.log(uuid.bitFields[4]); // "11011001" console.log(uuid.hexFields[5]);
二:文件上传下载拖拽文件 及文件夹等(rc-upload)
var Upload = require('rc-upload'); var React = require('react'); React.render(<Upload />, container);
三:一个用于格式化和处理数字的javascript库(numeral)
var value = myNumeral.value(); // 1000 var myNumeral2 = numeral('1,000'); var value2 = myNumeral2.value(); // 1000
四:JavaScript日期库(Moment.js)
功能:用于解析,验证,操作和格式化日期。
moment().format('MMMM Do YYYY, h:mm:ss a'); // December 22nd 2020, 10:55:15 am moment().format('dddd'); // Tuesday moment().format("MMM Do YY"); // Dec 22nd 20 moment().format('YYYY [escaped] YYYY'); // 2020 escaped 2020 moment().format();
五:轻量的处理时间和日期的 JavaScript 库(Day.js)
功能:Day.js 是一个轻量的处理时间和日期的 JavaScript 库,和 Moment.js 的 API 设计保持完全一样. 如果您曾经用过 Moment.js, 那么您已经知道如何使用 Day.js
ayjs().format('{YYYY} MM-DDTHH:mm:ss SSS [Z] A') // 展示 dayjs() .set('month', 3) .month() // 获取 dayjs().add(1, 'year') // 处理 dayjs().isBefore(dayjs()) // 查询
六:用于将时间转换为毫秒(milliseconds.js)
var ms = require('milliseconds'); ms.seconds(2); // 2000 ms.minutes(2); // 120000 ms.hours(2); // 7200000 ms.days(2); // 172800000 ms.weeks(2); // 1209600000 ms.months(2); // 5259600000 ms.years(2); // 63115200000
七:filesize
功能:filesize.js提供了一种简单的方法来从数字(浮点数或整数)或字符串中获取人类可读的文件大小字符串。
npm i filesize filesize(500); // "500 B" filesize(500, {bits: true}); // "4 Kb" filesize(265318, {base: 10}); // "265.32 kB" filesize(265318); // "259.1 KB" filesize(265318, {round: 0}); // "259 KB" filesize(265318, {output: "array"}); // [259.1, "KB"] filesize(265318, {output: "object"}); // {value: 259.1, symbol: "KB", exponent: 1} filesize(1, {symbols: {B: "Б"}}); // "1 Б" filesize(1024); // "1 KB" filesize(1024, {exponent: 0}); // "1024 B" filesize(1024, {output: "exponent"}); // 1 filesize(265318, {standard: "iec"}); // "259.1 KiB" filesize(265318, {standard: "iec", fullform: true}); // "259.1 kibibytes" filesize(12, {fullform: true, fullforms: ["байтов"]}); // "12 байтов" filesize(265318, {separator: ","}); // "259,1 KB" filesize(265318, {locale: "de"}); // "259,1 KB"
八:Base64转码器(js-base64)
功能:Base64转码器
npm install --save js-base64 require=require('esm')(module); import {Base64} from 'js-base64'; let latin = 'dankogai'; let utf8 = '小飼弾' let u8s = new Uint8Array([100,97,110,107,111,103,97,105]); Base64.encode(latin); // ZGFua29nYWk= Base64.btoa(latin); // ZGFua29nYWk= Base64.btoa(utf8); // raises exception Base64.fromUint8Array(u8s); // ZGFua29nYWk= Base64.fromUint8Array(u8s, true); // ZGFua29nYW which is URI safe Base64.encode(utf8); // 5bCP6aO85by+ Base64.encode(utf8, true) // 5bCP6aO85by- Base64.encodeURI(utf8); // 5bCP6aO85by-
九:将承诺推迟一定的时间(delay)
功能:将承诺推迟一定的时间
npm install delay const delay = require('delay'); (async () => { bar(); await delay(100); // Executed 100 milliseconds later baz(); })();