ng-number-to-text
Version:
Set of pipes for angular2+ projects to convert numbers to words as ordinal numbers
2 lines • 7.06 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ng-number-to-text",["exports","@angular/core"],e):e(t["ng-number-to-text"]={},t.ng.core)}(this,function(t,e){"use strict";var i=function(){function t(){}return t.prototype.transform=function(t){var e;return e=parseInt(t,10),"The "+this.checkNumber(e)},t.prototype.checkNumber=function(t){return this.checkZero(t)?"zeroth":0<t&&t<=10?this.checkSingle(t):10<t&&t<=20?this.checkTenth(t):20<t&&t<=30?this.checkTwentieth(t):30<t&&t<=40?this.checkThirtieth(t):40<t&&t<=50?this.checkFortieth(t):50<t&&t<=60?this.checkFiftieth(t):60<t&&t<=70?this.checkSixtieth(t):70<t&&t<=80?this.checkSeventieth(t):80<t&&t<=90?this.checkEightieth(t):90<t&&t<=100?this.checkNinetieth(t):void 0},t.prototype.checkZero=function(t){return 0===t},t.prototype.checkSingle=function(t){return t<10&&0<t?1===t?"first":2===t?"second":3===t?"third":4===t?"fourth":5===t?"fifth":6===t?"sixth":7===t?"seventh":8===t?"eighth":"ninth":"tenth"},t.prototype.checkTenth=function(t){return 10<t&&t<20?11===t?"eleventh":12===t?"twelfth":13===t?"thirteenth":14===t?"fourteenth":15===t?"fifteenth":16===t?"sixteenth":17===t?"seventeenth":18===t?"eighteenth":19===t?"nineteenth":void 0:"twentieth"},t.prototype.checkTwentieth=function(t){return 20<t&&t<30?(t-=20,"twenty-"+this.checkSingle(t)):"thirtieth"},t.prototype.checkThirtieth=function(t){return 30<t&&t<40?(t-=30,"thirty-"+this.checkSingle(t)):"fortieth"},t.prototype.checkFortieth=function(t){return 40<t&&t<50?(t-=40,"forty-"+this.checkSingle(t)):"fiftieth"},t.prototype.checkFiftieth=function(t){return 50<t&&t<60?(t-=50,"fifty-"+this.checkSingle(t)):"sixtieth"},t.prototype.checkSixtieth=function(t){return 60<t&&t<70?(t-=60,"sixty-"+this.checkSingle(t)):"seventieth"},t.prototype.checkSeventieth=function(t){return 70<t&&t<80?(t-=70,"seventy-"+this.checkSingle(t)):"eightieth"},t.prototype.checkEightieth=function(t){return 80<t&&t<90?(t-=80,"eighty-"+this.checkSingle(t)):"ninetieth"},t.prototype.checkNinetieth=function(t){return 90<t&&t<100?(t-=90,"ninety-"+this.checkSingle(t)):"hundredth"},t.decorators=[{type:e.Pipe,args:[{name:"numberToText"}]}],t}(),h=function(){function t(){this.first="الحادى"}return t.prototype.transform=function(t){var e;return e=parseInt(t,10),this.checkNumber(e)},t.prototype.checkNumber=function(t){return this.checkZero(t)?"الارضى":0<t&&t<=10?this.checkSingle(t):10<t&&t<=20?this.checkTenth(t):20<t&&t<=30?this.checkTwentieth(t):30<t&&t<=40?this.checkThirtieth(t):40<t&&t<=50?this.checkFortieth(t):50<t&&t<=60?this.checkFiftieth(t):60<t&&t<=70?this.checkSixtieth(t):70<t&&t<=80?this.checkSeventieth(t):80<t&&t<=90?this.checkEightieth(t):90<t&&t<=100?this.checkNinetieth(t):void 0},t.prototype.checkZero=function(t){return 0===t},t.prototype.checkSingle=function(t){return t<10&&0<t?1===t?"الاول":2===t?"الثانى":3===t?"الثالث":4===t?"الرابع":5===t?"الخامس":6===t?"السادس":7===t?"السابع":8===t?"الثامن":"التاسع":"العاشر"},t.prototype.checkTenth=function(t){return 10<t&&t<20?1===(t-=10)?"الحادى عشر":this.checkSingle(t)+" عشر":"العشرون"},t.prototype.checkTwentieth=function(t){var e=" و العشرون";return 20<t&&t<30?1===(t-=20)?this.first+e:this.checkSingle(t)+e:"الثلاثون"},t.prototype.checkThirtieth=function(t){var e=" و الثلاثون";return 30<t&&t<40?1===(t-=30)?this.first+e:this.checkSingle(t)+e:"الاربعون"},t.prototype.checkFortieth=function(t){var e=" و الاربعون";return 40<t&&t<50?1===(t-=40)?this.first+e:this.checkSingle(t)+e:"الخمسون"},t.prototype.checkFiftieth=function(t){var e=" و الخمسون";return 50<t&&t<60?1===(t-=50)?this.first+e:this.checkSingle(t)+e:"الستون"},t.prototype.checkSixtieth=function(t){var e=" و الستون";return 60<t&&t<70?1===(t-=60)?this.first+e:this.checkSingle(t)+e:"السبعون"},t.prototype.checkSeventieth=function(t){var e=" و السبعون";return 70<t&&t<80?1===(t-=70)?this.first+e:this.checkSingle(t)+e:"الثمانون"},t.prototype.checkEightieth=function(t){var e=" و الثمانون";return 80<t&&t<90?1===(t-=80)?this.first+e:this.checkSingle(t)+e:"التسعون"},t.prototype.checkNinetieth=function(t){var e=" و التسعون";return 90<t&&t<100?1===(t-=90)?this.first+e:this.checkSingle(t)+e:"المائة"},t.decorators=[{type:e.Pipe,args:[{name:"numberToTextAr"}]}],t}(),c=function(){function t(){this.first="الحادية"}return t.prototype.transform=function(t){var e;return e=parseInt(t,10),this.checkNumber(e)},t.prototype.checkNumber=function(t){return this.checkZero(t)?"الارضى":0<t&&t<=10?this.checkSingle(t):10<t&&t<=20?this.checkTenth(t):20<t&&t<=30?this.checkTwentieth(t):30<t&&t<=40?this.checkThirtieth(t):40<t&&t<=50?this.checkFortieth(t):50<t&&t<=60?this.checkFiftieth(t):60<t&&t<=70?this.checkSixtieth(t):70<t&&t<=80?this.checkSeventieth(t):80<t&&t<=90?this.checkEightieth(t):90<t&&t<=100?this.checkNinetieth(t):void 0},t.prototype.checkZero=function(t){return 0===t},t.prototype.checkSingle=function(t){return t<10&&0<t?1===t?"الاولى":2===t?"الثانية":3===t?"الثالثة":4===t?"الرابعة":5===t?"الخامسة":6===t?"السادسة":7===t?"السابعة":8===t?"الثامنة":"التاسعة":"العاشرة"},t.prototype.checkTenth=function(t){return 10<t&&t<20?1===(t-=10)?"الحادية عشر":this.checkSingle(t)+" عشر":"العشرون"},t.prototype.checkTwentieth=function(t){var e=" و العشرون";return 20<t&&t<30?1===(t-=20)?this.first+e:this.checkSingle(t)+e:"الثلاثون"},t.prototype.checkThirtieth=function(t){var e=" و الثلاثون";return 30<t&&t<40?1===(t-=30)?this.first+e:this.checkSingle(t)+e:"الاربعون"},t.prototype.checkFortieth=function(t){var e=" و الاربعون";return 40<t&&t<50?1===(t-=40)?this.first+e:this.checkSingle(t)+e:"الخمسون"},t.prototype.checkFiftieth=function(t){var e=" و الخمسون";return 50<t&&t<60?1===(t-=50)?this.first+e:this.checkSingle(t)+e:"الستون"},t.prototype.checkSixtieth=function(t){var e=" و الستون";return 60<t&&t<70?1===(t-=60)?this.first+e:this.checkSingle(t)+e:"السبعون"},t.prototype.checkSeventieth=function(t){var e=" و السبعون";return 70<t&&t<80?1===(t-=70)?this.first+e:this.checkSingle(t)+e:"الثمانون"},t.prototype.checkEightieth=function(t){var e=" و الثمانون";return 80<t&&t<90?1===(t-=80)?this.first+e:this.checkSingle(t)+e:"التسعون"},t.prototype.checkNinetieth=function(t){var e=" و التسعون";return 90<t&&t<100?1===(t-=90)?this.first+e:this.checkSingle(t)+e:"المائة"},t.decorators=[{type:e.Pipe,args:[{name:"numberToTextArFem"}]}],t}(),n=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[],declarations:[i,h,c],exports:[i,h,c]}]}],t}();t.NumberToTextModule=n,t.ɵc=c,t.ɵb=h,t.ɵa=i,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-number-to-text.umd.min.js.map