@ngx-mask/core
Version:
[@ngx-mask/core](https://github.com/IKatsuba/ngx-mask#readme)
34 lines • 1.41 kB
JavaScript
import { __decorate, __metadata, __param } from "tslib";
import { Inject, Injectable } from '@angular/core';
import { NGX_MASK_OPTIONS } from './tokens';
import { Mask } from './mask';
import * as i0 from "@angular/core";
import * as i1 from "./tokens";
let NgxMaskService = class NgxMaskService {
constructor(options) {
this.options = options;
this.validateTokens(options.tokens);
}
applyMask(value, mask, options) {
return Mask.applyMask(value, mask, Object.assign(Object.assign({}, this.options), options));
}
validateTokens(tokens) {
const token = Object.keys((tokens !== null && tokens !== void 0 ? tokens : {})).find(key => key.length !== 1);
if (token) {
throw new Error(`Token length must be 1! Actual token '${token}'`);
}
}
};
NgxMaskService.ctorParameters = () => [
{ type: undefined, decorators: [{ type: Inject, args: [NGX_MASK_OPTIONS,] }] }
];
NgxMaskService.ɵprov = i0.ɵɵdefineInjectable({ factory: function NgxMaskService_Factory() { return new NgxMaskService(i0.ɵɵinject(i1.NGX_MASK_OPTIONS)); }, token: NgxMaskService, providedIn: "root" });
NgxMaskService = __decorate([
Injectable({
providedIn: 'root'
}),
__param(0, Inject(NGX_MASK_OPTIONS)),
__metadata("design:paramtypes", [Object])
], NgxMaskService);
export { NgxMaskService };
//# sourceMappingURL=mask.service.js.map