UNPKG

ddbitemsizer

Version:
16 lines (15 loc) 396 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.bytes = void 0; /** * @description Returns the number of UTF-8 bytes of a string. * @example * ``` * const size = bytes('Hi!'); * console.log('The size of the string was:', size); // 'The size of the string was: 3' * ``` */ function bytes(str) { return new Blob([str]).size; } exports.bytes = bytes;