ng-anonymize
Version:
Data anonymization library for Angular
16 lines (14 loc) • 3.77 kB
JavaScript
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ng-anonymize",["exports","@angular/core"],n):n((e=e||self)["ng-anonymize"]={},e.ng.core)}(this,(function(e,n){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function t(e,n,t,o){var r,i=arguments.length,a=i<3?n:null===o?o=Object.getOwnPropertyDescriptor(n,t):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,n,t,o);else for(var f=e.length-1;f>=0;f--)(r=e[f])&&(a=(i<3?r(a):i>3?r(n,t,a):r(n,t))||a);return i>3&&a&&Object.defineProperty(n,t,a),a}var o,r={PhoneCcLength:3,MaskChar:"*",LeftReveal:3,RightReveal:4};(o=e.AnonymizeMethod||(e.AnonymizeMethod={})).Randomize="randomize",o.Shuffle="shuffle",o.First="first",o.Last="last";var i=[{name:e.AnonymizeMethod.Randomize,label:"Randomize"},{name:e.AnonymizeMethod.Shuffle,label:"Shuffle"},{name:e.AnonymizeMethod.First,label:"First"},{name:e.AnonymizeMethod.Last,label:"Last"}];(e.AnonymizeDataType||(e.AnonymizeDataType={})).Phone="phone";var a="abcdefghijjklmnopqrstuvwyz",f=a.split(""),u=a.toUpperCase().split(""),l="0123456789".split(""),d=function(){function o(){}return o.prototype.transform=function(n,t,o){if(void 0===t&&(t=e.AnonymizeMethod.Randomize),!n)return"";var i=o||{},a=i.type,d=i.mask,c=void 0===d?r.MaskChar:d,p=i.bleed;switch(t){case e.AnonymizeMethod.First:return n.split("").map((function(e,n){return n<(p||r.LeftReveal)?e:c})).join("");case e.AnonymizeMethod.Last:return n.split("").map((function(e,t){return t>=n.length-(p||r.RightReveal)?e:c})).join("");case e.AnonymizeMethod.Randomize:return n.split("").map((function(n,t){var o=f.indexOf(n)>=0,i=u.indexOf(n)>=0,d=l.indexOf(n)>=0,c=o?f:i?u:d?l:null;return c?a===e.AnonymizeDataType.Phone&&t<r.PhoneCcLength?n:c[Math.floor(Math.random()*c.length)]:n})).join("");case e.AnonymizeMethod.Shuffle:var s=n.split(""),m=s.filter((function(e){return f.indexOf(e)>=0||u.indexOf(e)>=0})).sort((function(){return.5-Math.random()})),h=s.filter((function(e){return l.indexOf(e)>=0})).sort((function(){return.5-Math.random()}));return s.map((function(n,t){var o=f.indexOf(n)>=0,i=u.indexOf(n)>=0,d=l.indexOf(n)>=0;if(!(o?f:i?u:d?l:null))return n;if(a===e.AnonymizeDataType.Phone&&t<r.PhoneCcLength)return n;var c=d?h.pop():m.pop();return i?c=c.toUpperCase():o&&(c=c.toLowerCase()),c})).join("");default:return n||""}},o=t([n.Pipe({name:"anonymize",pure:!0})],o)}(),c=function(){function e(){}return e.ɵprov=n["ɵɵdefineInjectable"]({factory:function(){return new e},token:e,providedIn:"root"}),e=t([n.Injectable({providedIn:"root"})],e)}(),p=function(){function e(){}return e=t([n.NgModule({declarations:[d],imports:[],exports:[d]})],e)}();e.AnonymizeDefaultValues=r,e.AnonymizeMethods=i,e.AnonymizePipe=d,e.NgAnonymizeModule=p,e.NgAnonymizeService=c,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-anonymize.umd.min.js.map