@dazejs/framework
Version:
Daze.js - A powerful web framework for Node.js
95 lines • 3.27 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Str = void 0;
const _ = __importStar(require("underscore.string"));
const crypto_1 = __importDefault(require("crypto"));
class Str {
static formatPrefix(prefix = '') {
let prefixed = prefix.slice(0, 1) === '/' ? prefix : `/${prefix}`;
prefixed = prefixed.slice(-1) === '/' ? prefixed.slice(0, prefixed.length - 1) : prefixed;
return prefixed;
}
static decodeBASE64(str) {
const body = Buffer.from(str, 'base64').toString('utf8');
return JSON.parse(body);
}
static encodeBASE64(body) {
return Buffer.from(JSON.stringify(body)).toString('base64');
}
static aesEncrypt(val, key, iv = null) {
const cipher = crypto_1.default.createCipheriv('aes-256-cbc', key, iv);
let encrypted = cipher.update(val, 'utf8', 'base64');
encrypted += cipher.final('base64');
return encrypted;
}
}
exports.Str = Str;
Str.slugify = _.slugify;
Str.numberFormat = _.numberFormat;
Str.capitalize = _.capitalize;
Str.decapitalize = _.decapitalize;
Str.titleize = _.titleize;
Str.camelize = _.camelize;
Str.swapCase = _.swapCase;
Str.chop = _.chop;
Str.chars = _.chars;
Str.include = _.include;
Str.count = _.count;
Str.escapeHTML = _.escapeHTML;
Str.unescapeHTML = _.unescapeHTML;
Str.insert = _.insert;
Str.isBlank = _.isBlank;
Str.join = _.join;
Str.lines = _.lines;
Str.words = _.words;
Str.reverse = _.reverse;
Str.startsWith = _.startsWith;
Str.endsWith = _.endsWith;
Str.classify = _.classify;
Str.underscored = _.underscored;
Str.trim = _.trim;
Str.truncate = _.truncate;
Str.prune = _.prune;
Str.sprintf = _.sprintf;
Str.pad = _.pad;
Str.lpad = _.lpad;
Str.rpad = _.rpad;
Str.lrpad = _.lrpad;
Str.toNumber = _.toNumber;
Str.repeat = _.repeat;
Str.surround = _.surround;
Str.quote = _.quote;
Str.unquote = _.unquote;
Str.toBoolean = _.toBoolean;
Str.strRight = _.strRight;
Str.strRightBack = _.strRightBack;
Str.strLeft = _.strLeft;
Str.strLeftBack = _.strLeftBack;
Str.stripTags = _.stripTags;
//# sourceMappingURL=str.js.map