ngx-bit
Version:
A flexible NG-ZORRO helper library
72 lines (62 loc) • 2.52 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('ngx-bit/operates', ['exports', 'rxjs', 'rxjs/operators'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['ngx-bit'] = global['ngx-bit'] || {}, global['ngx-bit'].operates = {}), global.rxjs, global.rxjs.operators));
}(this, (function (exports, rxjs, operators) { 'use strict';
function asyncValidator(handle, field, dueTime) {
if (field === void 0) { field = 'duplicated'; }
if (dueTime === void 0) { dueTime = 500; }
return rxjs.timer(dueTime).pipe(operators.switchMap(function () { return handle; }), operators.map(function (result) {
var _a;
return !result ? (_a = { error: true }, _a[field] = true, _a) : null;
}));
}
function empty(value) {
if ([undefined, null, '', 0, false].includes(value)) {
return true;
}
if (typeof value === 'object') {
return Object.keys(value).length === 0;
}
return false;
}
function print(str) {
var vars = [];
for (var _i = 1; _i < arguments.length; _i++) {
vars[_i - 1] = arguments[_i];
}
if (!str) {
return '';
}
vars.forEach(function (value, index) {
str = str.replace('$' + index, value);
});
return str;
}
function privacy(text, start, end) {
var match = text.slice(start, end);
return text.replace(match, '*'.repeat(match.length));
}
function loadScript(doc, url) {
var script = doc.createElement('script');
script.type = 'text/javascript';
script.src = url;
doc.body.appendChild(script);
return new rxjs.Observable(function (subscriber) {
script.onload = function () {
subscriber.next();
subscriber.complete();
};
});
}
/**
* Generated bundle index. Do not edit.
*/
exports.asyncValidator = asyncValidator;
exports.empty = empty;
exports.loadScript = loadScript;
exports.print = print;
exports.privacy = privacy;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=ngx-bit-operates.umd.js.map