source: trip-planner-front/node_modules/memfs/lib/encoding.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 831 bytes
Line 
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.strToEncoding = exports.assertEncoding = exports.ENCODING_UTF8 = void 0;
4var buffer_1 = require("./internal/buffer");
5var errors = require("./internal/errors");
6exports.ENCODING_UTF8 = 'utf8';
7function assertEncoding(encoding) {
8 if (encoding && !buffer_1.Buffer.isEncoding(encoding))
9 throw new errors.TypeError('ERR_INVALID_OPT_VALUE_ENCODING', encoding);
10}
11exports.assertEncoding = assertEncoding;
12function strToEncoding(str, encoding) {
13 if (!encoding || encoding === exports.ENCODING_UTF8)
14 return str; // UTF-8
15 if (encoding === 'buffer')
16 return new buffer_1.Buffer(str); // `buffer` encoding
17 return new buffer_1.Buffer(str).toString(encoding); // Custom encoding
18}
19exports.strToEncoding = strToEncoding;
Note: See TracBrowser for help on using the repository browser.