yummies 7.12.0 → 7.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -87
- package/async.cjs +17 -0
- package/async.cjs.map +1 -1
- package/async.d.ts +17 -0
- package/async.js +17 -0
- package/async.js.map +1 -1
- package/common.cjs.map +1 -1
- package/common.d.ts +18 -0
- package/common.js.map +1 -1
- package/complex.cjs.map +1 -1
- package/complex.d.ts +66 -0
- package/complex.js.map +1 -1
- package/cookie.cjs.map +1 -1
- package/cookie.d.ts +18 -0
- package/cookie.js.map +1 -1
- package/css.cjs +16 -0
- package/css.cjs.map +1 -1
- package/css.d.ts +17 -0
- package/css.js +16 -0
- package/css.js.map +1 -1
- package/data.cjs.map +1 -1
- package/data.d.ts +18 -0
- package/data.js.map +1 -1
- package/date-time.cjs +16 -0
- package/date-time.cjs.map +1 -1
- package/date-time.d.ts +17 -0
- package/date-time.js +16 -0
- package/date-time.js.map +1 -1
- package/device.cjs +17 -0
- package/device.cjs.map +1 -1
- package/device.d.ts +17 -0
- package/device.js +17 -0
- package/device.js.map +1 -1
- package/encodings.cjs.map +1 -1
- package/encodings.d.ts +17 -0
- package/encodings.js.map +1 -1
- package/errors.cjs +16 -0
- package/errors.cjs.map +1 -1
- package/errors.d.ts +17 -0
- package/errors.js +16 -0
- package/errors.js.map +1 -1
- package/file.cjs +16 -0
- package/file.cjs.map +1 -1
- package/file.d.ts +16 -0
- package/file.js +16 -0
- package/file.js.map +1 -1
- package/format.cjs.map +1 -1
- package/format.d.ts +18 -0
- package/format.js.map +1 -1
- package/html.cjs +16 -0
- package/html.cjs.map +1 -1
- package/html.d.ts +17 -0
- package/html.js +16 -0
- package/html.js.map +1 -1
- package/id.cjs +16 -0
- package/id.cjs.map +1 -1
- package/id.d.ts +16 -0
- package/id.js +16 -0
- package/id.js.map +1 -1
- package/imports.cjs +16 -0
- package/imports.cjs.map +1 -1
- package/imports.d.ts +16 -0
- package/imports.js +16 -0
- package/imports.js.map +1 -1
- package/math.cjs.map +1 -1
- package/math.d.ts +17 -0
- package/math.js.map +1 -1
- package/media.cjs +16 -0
- package/media.cjs.map +1 -1
- package/media.d.ts +16 -0
- package/media.js +16 -0
- package/media.js.map +1 -1
- package/mobx.cjs +96 -0
- package/mobx.cjs.map +1 -1
- package/mobx.d.ts +101 -0
- package/mobx.js +96 -0
- package/mobx.js.map +1 -1
- package/ms.cjs +16 -0
- package/ms.cjs.map +1 -1
- package/ms.d.ts +16 -0
- package/ms.js +16 -0
- package/ms.js.map +1 -1
- package/number.cjs +16 -0
- package/number.cjs.map +1 -1
- package/number.d.ts +16 -0
- package/number.js +16 -0
- package/number.js.map +1 -1
- package/package.json +2 -2
- package/parser.cjs.map +1 -1
- package/parser.d.ts +17 -0
- package/parser.js.map +1 -1
- package/price.cjs.map +1 -1
- package/price.d.ts +16 -0
- package/price.js.map +1 -1
- package/random.cjs +16 -0
- package/random.cjs.map +1 -1
- package/random.d.ts +16 -0
- package/random.js +16 -0
- package/random.js.map +1 -1
- package/sound.cjs +16 -0
- package/sound.cjs.map +1 -1
- package/sound.d.ts +16 -0
- package/sound.js +16 -0
- package/sound.js.map +1 -1
- package/storage.cjs.map +1 -1
- package/storage.d.ts +16 -0
- package/storage.js.map +1 -1
- package/text.cjs +16 -0
- package/text.cjs.map +1 -1
- package/text.d.ts +16 -0
- package/text.js +16 -0
- package/text.js.map +1 -1
- package/type-guard.cjs.map +1 -1
- package/type-guard.d.ts +18 -0
- package/type-guard.js.map +1 -1
- package/types.d.ts +41 -0
- package/types.global.d.ts +41 -0
- package/vibrate.cjs +16 -0
- package/vibrate.cjs.map +1 -1
- package/vibrate.d.ts +16 -0
- package/vibrate.js +16 -0
- package/vibrate.js.map +1 -1
package/date-time.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date-time.js","names":[],"sources":["../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/plugin/duration.js","../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/plugin/relativeTime.js","../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/locale/ru.js","../src/date-time.ts"],"sourcesContent":["!function(t,s){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=s():\"function\"==typeof define&&define.amd?define(s):(t=\"undefined\"!=typeof globalThis?globalThis:t||self).dayjs_plugin_duration=s()}(this,(function(){\"use strict\";var t,s,n=1e3,i=6e4,e=36e5,r=864e5,o=/\\[([^\\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,u=31536e6,d=2628e6,a=/^(-|\\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,h={years:u,months:d,days:r,hours:e,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},c=function(t){return t instanceof g},f=function(t,s,n){return new g(t,n,s.$l)},m=function(t){return s.p(t)+\"s\"},l=function(t){return t<0},$=function(t){return l(t)?Math.ceil(t):Math.floor(t)},y=function(t){return Math.abs(t)},v=function(t,s){return t?l(t)?{negative:!0,format:\"\"+y(t)+s}:{negative:!1,format:\"\"+t+s}:{negative:!1,format:\"\"}},g=function(){function l(t,s,n){var i=this;if(this.$d={},this.$l=n,void 0===t&&(this.$ms=0,this.parseFromMilliseconds()),s)return f(t*h[m(s)],this);if(\"number\"==typeof t)return this.$ms=t,this.parseFromMilliseconds(),this;if(\"object\"==typeof t)return Object.keys(t).forEach((function(s){i.$d[m(s)]=t[s]})),this.calMilliseconds(),this;if(\"string\"==typeof t){var e=t.match(a);if(e){var r=e.slice(2).map((function(t){return null!=t?Number(t):0}));return this.$d.years=r[0],this.$d.months=r[1],this.$d.weeks=r[2],this.$d.days=r[3],this.$d.hours=r[4],this.$d.minutes=r[5],this.$d.seconds=r[6],this.calMilliseconds(),this}}return this}var y=l.prototype;return y.calMilliseconds=function(){var t=this;this.$ms=Object.keys(this.$d).reduce((function(s,n){return s+(t.$d[n]||0)*h[n]}),0)},y.parseFromMilliseconds=function(){var t=this.$ms;this.$d.years=$(t/u),t%=u,this.$d.months=$(t/d),t%=d,this.$d.days=$(t/r),t%=r,this.$d.hours=$(t/e),t%=e,this.$d.minutes=$(t/i),t%=i,this.$d.seconds=$(t/n),t%=n,this.$d.milliseconds=t},y.toISOString=function(){var t=v(this.$d.years,\"Y\"),s=v(this.$d.months,\"M\"),n=+this.$d.days||0;this.$d.weeks&&(n+=7*this.$d.weeks);var i=v(n,\"D\"),e=v(this.$d.hours,\"H\"),r=v(this.$d.minutes,\"M\"),o=this.$d.seconds||0;this.$d.milliseconds&&(o+=this.$d.milliseconds/1e3,o=Math.round(1e3*o)/1e3);var u=v(o,\"S\"),d=t.negative||s.negative||i.negative||e.negative||r.negative||u.negative,a=e.format||r.format||u.format?\"T\":\"\",h=(d?\"-\":\"\")+\"P\"+t.format+s.format+i.format+a+e.format+r.format+u.format;return\"P\"===h||\"-P\"===h?\"P0D\":h},y.toJSON=function(){return this.toISOString()},y.format=function(t){var n=t||\"YYYY-MM-DDTHH:mm:ss\",i={Y:this.$d.years,YY:s.s(this.$d.years,2,\"0\"),YYYY:s.s(this.$d.years,4,\"0\"),M:this.$d.months,MM:s.s(this.$d.months,2,\"0\"),D:this.$d.days,DD:s.s(this.$d.days,2,\"0\"),H:this.$d.hours,HH:s.s(this.$d.hours,2,\"0\"),m:this.$d.minutes,mm:s.s(this.$d.minutes,2,\"0\"),s:this.$d.seconds,ss:s.s(this.$d.seconds,2,\"0\"),SSS:s.s(this.$d.milliseconds,3,\"0\")};return n.replace(o,(function(t,s){return s||String(i[t])}))},y.as=function(t){return this.$ms/h[m(t)]},y.get=function(t){var s=this.$ms,n=m(t);return\"milliseconds\"===n?s%=1e3:s=\"weeks\"===n?$(s/h[n]):this.$d[n],s||0},y.add=function(t,s,n){var i;return i=s?t*h[m(s)]:c(t)?t.$ms:f(t,this).$ms,f(this.$ms+i*(n?-1:1),this)},y.subtract=function(t,s){return this.add(t,s,!0)},y.locale=function(t){var s=this.clone();return s.$l=t,s},y.clone=function(){return f(this.$ms,this)},y.humanize=function(s){return t().add(this.$ms,\"ms\").locale(this.$l).fromNow(!s)},y.valueOf=function(){return this.asMilliseconds()},y.milliseconds=function(){return this.get(\"milliseconds\")},y.asMilliseconds=function(){return this.as(\"milliseconds\")},y.seconds=function(){return this.get(\"seconds\")},y.asSeconds=function(){return this.as(\"seconds\")},y.minutes=function(){return this.get(\"minutes\")},y.asMinutes=function(){return this.as(\"minutes\")},y.hours=function(){return this.get(\"hours\")},y.asHours=function(){return this.as(\"hours\")},y.days=function(){return this.get(\"days\")},y.asDays=function(){return this.as(\"days\")},y.weeks=function(){return this.get(\"weeks\")},y.asWeeks=function(){return this.as(\"weeks\")},y.months=function(){return this.get(\"months\")},y.asMonths=function(){return this.as(\"months\")},y.years=function(){return this.get(\"years\")},y.asYears=function(){return this.as(\"years\")},l}(),p=function(t,s,n){return t.add(s.years()*n,\"y\").add(s.months()*n,\"M\").add(s.days()*n,\"d\").add(s.hours()*n,\"h\").add(s.minutes()*n,\"m\").add(s.seconds()*n,\"s\").add(s.milliseconds()*n,\"ms\")};return function(n,i,e){t=e,s=e().$utils(),e.duration=function(t,s){var n=e.locale();return f(t,{$l:n},s)},e.isDuration=c;var r=i.prototype.add,o=i.prototype.subtract;i.prototype.add=function(t,s){return c(t)?p(this,t,1):r.bind(this)(t,s)},i.prototype.subtract=function(t,s){return c(t)?p(this,t,-1):o.bind(this)(t,s)}}}));","!function(r,e){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=e():\"function\"==typeof define&&define.amd?define(e):(r=\"undefined\"!=typeof globalThis?globalThis:r||self).dayjs_plugin_relativeTime=e()}(this,(function(){\"use strict\";return function(r,e,t){r=r||{};var n=e.prototype,o={future:\"in %s\",past:\"%s ago\",s:\"a few seconds\",m:\"a minute\",mm:\"%d minutes\",h:\"an hour\",hh:\"%d hours\",d:\"a day\",dd:\"%d days\",M:\"a month\",MM:\"%d months\",y:\"a year\",yy:\"%d years\"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:\"s\",r:44,d:\"second\"},{l:\"m\",r:89},{l:\"mm\",r:44,d:\"minute\"},{l:\"h\",r:89},{l:\"hh\",r:21,d:\"hour\"},{l:\"d\",r:35},{l:\"dd\",r:25,d:\"day\"},{l:\"M\",r:45},{l:\"MM\",r:10,d:\"month\"},{l:\"y\",r:17},{l:\"yy\",d:\"year\"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,!0):i.diff(e,y.d,!0));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(\"\"+p)),a=\"string\"==typeof v?v.replace(\"%d\",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return\"function\"==typeof M?M(a):M.replace(\"%s\",a)},n.to=function(r,e){return i(r,e,this,!0)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)}}}));","!function(_,t){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=t(require(\"dayjs\")):\"function\"==typeof define&&define.amd?define([\"dayjs\"],t):(_=\"undefined\"!=typeof globalThis?globalThis:_||self).dayjs_locale_ru=t(_.dayjs)}(this,(function(_){\"use strict\";function t(_){return _&&\"object\"==typeof _&&\"default\"in _?_:{default:_}}var e=t(_),n=\"января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря\".split(\"_\"),s=\"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь\".split(\"_\"),r=\"янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.\".split(\"_\"),o=\"янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.\".split(\"_\"),i=/D[oD]?(\\[[^[\\]]*\\]|\\s)+MMMM?/;function d(_,t,e){var n,s;return\"m\"===e?t?\"минута\":\"минуту\":_+\" \"+(n=+_,s={mm:t?\"минута_минуты_минут\":\"минуту_минуты_минут\",hh:\"час_часа_часов\",dd:\"день_дня_дней\",MM:\"месяц_месяца_месяцев\",yy:\"год_года_лет\"}[e].split(\"_\"),n%10==1&&n%100!=11?s[0]:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?s[1]:s[2])}var u=function(_,t){return i.test(t)?n[_.month()]:s[_.month()]};u.s=s,u.f=n;var a=function(_,t){return i.test(t)?r[_.month()]:o[_.month()]};a.s=o,a.f=r;var m={name:\"ru\",weekdays:\"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота\".split(\"_\"),weekdaysShort:\"вск_пнд_втр_срд_чтв_птн_сбт\".split(\"_\"),weekdaysMin:\"вс_пн_вт_ср_чт_пт_сб\".split(\"_\"),months:u,monthsShort:a,weekStart:1,yearStart:4,formats:{LT:\"H:mm\",LTS:\"H:mm:ss\",L:\"DD.MM.YYYY\",LL:\"D MMMM YYYY г.\",LLL:\"D MMMM YYYY г., H:mm\",LLLL:\"dddd, D MMMM YYYY г., H:mm\"},relativeTime:{future:\"через %s\",past:\"%s назад\",s:\"несколько секунд\",m:d,mm:d,h:\"час\",hh:d,d:\"день\",dd:d,M:\"месяц\",MM:d,y:\"год\",yy:d},ordinal:function(_){return _},meridiem:function(_){return _<4?\"ночи\":_<12?\"утра\":_<17?\"дня\":\"вечера\"}};return e.default.locale(m,null,!0),m}));","import dayjs, { type Dayjs, type ManipulateType } from 'dayjs';\nimport duration from 'dayjs/plugin/duration.js';\nimport relativeTime from 'dayjs/plugin/relativeTime.js';\nimport { format } from 'yummies/format';\nimport { ms, unitsToMs } from 'yummies/ms';\nimport { declension } from 'yummies/text';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\nimport 'dayjs/locale/ru.js';\n\ndayjs.extend(relativeTime);\ndayjs.extend(duration);\ndayjs.locale('ru');\n\nconst toLibFormat = (value: Maybe<RawDateToFormat>): Dayjs | null => {\n let result: Maybe<Dayjs> = null;\n if (dayjs.isDayjs(value)) {\n result = value;\n } else if (value != null) {\n result = dayjs(value);\n }\n\n if (!result?.isValid()) {\n return null;\n }\n\n return result;\n};\n\nexport type RawDateToFormat = Date | string | number | Dayjs;\n\n/**\n * Formats a date-like value using predefined presets or a custom pattern.\n *\n * @example\n * ```ts\n * formatDate('2024-03-15', { format: 'time-short' });\n * ```\n */\nexport const formatDate = (\n value: Maybe<RawDateToFormat>,\n settings?: Maybe<{\n format?:\n | 'human'\n | 'full'\n | 'short'\n | 'day'\n | 'day-only'\n | 'date'\n | 'month'\n | 'spent-time'\n | 'time'\n | 'time-short';\n pattern?: string;\n asTime?: boolean;\n }>,\n) => {\n const dateFormat = settings?.format;\n const datePattern = settings?.pattern;\n const asTime = settings?.asTime;\n\n let libDate: duration.Duration | dayjs.Dayjs | null = null;\n\n if (asTime && typeGuard.isNumber(value)) {\n libDate = dayjs.duration(value);\n } else {\n libDate = toLibFormat(value);\n }\n\n if (!libDate) {\n return format.NO_VALUE;\n }\n\n if (datePattern) {\n return libDate.format(datePattern);\n }\n\n if (dateFormat === 'human' || dateFormat === 'spent-time') {\n if ('fromNow' in libDate) {\n return libDate.fromNow(dateFormat === 'spent-time');\n } else {\n return format.NO_VALUE;\n }\n }\n\n switch (dateFormat) {\n case 'full': {\n return libDate.format('DD MMM YYYY HH:mm:ss');\n }\n case 'short': {\n return libDate.format('DD MMM HH:mm');\n }\n case 'time': {\n return libDate.format('HH:mm:ss');\n }\n case 'time-short': {\n return libDate.format('HH:mm');\n }\n case 'day': {\n return libDate.format('DD MMM YYYY');\n }\n case 'month': {\n return libDate.format('MMMM YYYY');\n }\n default: {\n return libDate.format('DD.MM.YYYY');\n }\n }\n};\n\n/**\n * Splits a duration in milliseconds into day-based time parts.\n *\n * @example\n * ```ts\n * dayTimeDuration(ms(1, 'day') + ms(2, 'hour'));\n * ```\n */\nexport const dayTimeDuration = (timeInMs: number) => {\n let left = Math.max(timeInMs, 0);\n\n const days = Math.floor(left / unitsToMs.day);\n left = left % unitsToMs.day;\n\n const hours = Math.floor(left / unitsToMs.hour);\n left = left % unitsToMs.hour;\n\n const minutes = Math.floor(left / unitsToMs.min);\n left = left % unitsToMs.min;\n\n const seconds = Math.floor(left / unitsToMs.sec);\n left = left % unitsToMs.sec;\n\n const milliseconds = Math.floor(left);\n\n return {\n days,\n hours,\n minutes,\n seconds,\n milliseconds,\n };\n};\n\ntype DateChangeParam = [amount: number, unit?: Maybe<ManipulateType>];\n\n/**\n * Applies one or more date adjustments and returns a new `Date` instance.\n *\n * @example\n * ```ts\n * changeDate(new Date(), 1, 'day', 30, 'minute');\n * ```\n */\nexport const changeDate = (\n date: Maybe<RawDateToFormat>,\n ...args: [\n ...DateChangeParam,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ]\n) => {\n let wrappedDate = toLibFormat(date)!;\n\n for (let i = 0; i < args.length; i += 2) {\n const amount = args[i] as DateChangeParam[0];\n const unit = args[i + 1] as DateChangeParam[1];\n if (unit != null) {\n wrappedDate = wrappedDate.add(amount, unit);\n }\n }\n\n return wrappedDate.toDate();\n};\n\n/**\n * Converts milliseconds into hour-based time parts without keeping full days separately.\n *\n * @example\n * ```ts\n * timeDuration(ms(1, 'hour') + ms(30, 'min'));\n * ```\n */\nexport const timeDuration = (timeInMs: number) => {\n const { days, hours, milliseconds, minutes, seconds } =\n dayTimeDuration(timeInMs);\n\n return {\n hours: hours + unitsToMs.day * days,\n milliseconds,\n minutes,\n seconds,\n };\n};\n\nconst durationFormatLabels = {\n days: { compact: 'д', full: ['день', 'дня', 'дней'] },\n hours: { compact: 'ч', full: ['час', 'часа', 'часов'] },\n minutes: { compact: 'мин', full: ['минута', 'минуты', 'минут'] },\n seconds: { compact: 'сек', full: ['секунда', 'секунды', 'секунд'] },\n} as const;\n\n/**\n * Formats a duration either from milliseconds or between two dates.\n *\n * @example\n * ```ts\n * getFormatDuration(ms(2, 'hour') + ms(15, 'min'));\n * ```\n */\nexport function getFormatDuration(\n dateA: Date,\n dateB: Date,\n compact?: boolean,\n): string;\nexport function getFormatDuration(ms: number, compact?: boolean): string;\n\nexport function getFormatDuration(...args: any[]): string {\n let compact = false;\n let diff = 0;\n\n if (args[0] instanceof Date) {\n const startedDate = dayjs(args[0]);\n const endedDate = dayjs(args[1]);\n\n diff = endedDate.diff(startedDate, 'ms');\n compact = args[2] === true;\n } else {\n diff = args[0];\n compact = args[1] === true;\n }\n\n const { days, hours, minutes, seconds } = dayTimeDuration(diff);\n\n const formattedParts: string[] = [];\n\n if (days) {\n if (compact) {\n formattedParts.push(`${days} ${durationFormatLabels.days.compact}`);\n } else {\n formattedParts.push(\n `${days} ${declension(days, durationFormatLabels.days.full)}`,\n );\n }\n }\n\n if (hours) {\n if (compact) {\n formattedParts.push(`${hours} ${durationFormatLabels.hours.compact}`);\n } else {\n formattedParts.push(\n `${hours} ${declension(hours, durationFormatLabels.hours.full)}`,\n );\n }\n }\n\n if (minutes) {\n if (compact) {\n formattedParts.push(`${minutes} ${durationFormatLabels.minutes.compact}`);\n } else {\n formattedParts.push(\n `${minutes} ${declension(minutes, durationFormatLabels.minutes.full)}`,\n );\n }\n }\n\n if (seconds) {\n if (compact) {\n formattedParts.push(`${seconds} ${durationFormatLabels.seconds.compact}`);\n } else {\n formattedParts.push(\n `${seconds} ${declension(seconds, durationFormatLabels.seconds.full)}`,\n );\n }\n }\n\n return formattedParts.join(' ');\n}\n\nexport type TimeDiff = {\n minutes: number;\n seconds: number;\n total: {\n ms: number;\n hours: number;\n };\n};\n\n/**\n * Calculates the difference between two dates in minutes, seconds and total units.\n *\n * @example\n * ```ts\n * getTimeDiff(new Date('2024-03-15T12:30:00'), new Date('2024-03-15T12:00:00'));\n * ```\n */\nexport const getTimeDiff = (\n dateA: RawDateToFormat,\n dateB: RawDateToFormat,\n): TimeDiff => {\n const leftDate = toLibFormat(dateA)?.toDate();\n const rightDate = toLibFormat(dateB)?.toDate();\n\n if (!leftDate || !rightDate) {\n return {\n minutes: 0,\n seconds: 0,\n total: { ms: 0, hours: 0 },\n };\n }\n\n const msDiff = leftDate.getTime() - rightDate.getTime();\n\n return {\n minutes: Math.max(Math.floor(msDiff / ms(1, 'min')), 0),\n seconds: Math.max(Math.floor((msDiff % ms(1, 'min')) / 1000), 0),\n total: {\n hours: Math.round(msDiff / ms(1, 'hour')),\n ms: msDiff,\n },\n };\n};\n\n/**\n * Returns a new date shifted forward by the provided number of days.\n *\n * @example\n * ```ts\n * addDays(new Date('2024-03-15'), 7);\n * ```\n */\nexport const addDays = (date: RawDateToFormat, count: number) =>\n toLibFormat(date)?.add(count, 'd').toDate();\n\n/**\n * Returns a new date shifted backward by the provided number of days.\n *\n * @example\n * ```ts\n * subtractDays(new Date('2024-03-15'), 7);\n * ```\n */\nexport const subtractDays = (date: RawDateToFormat, count: number) =>\n toLibFormat(date)?.subtract(count, 'd').toDate();\n\n/**\n * Returns a new date shifted forward by the provided number of minutes.\n *\n * @example\n * ```ts\n * addMinutes(new Date('2024-03-15T12:00:00'), 15);\n * ```\n */\nexport const addMinutes = (date: RawDateToFormat, count: number) =>\n toLibFormat(date)?.add(count, 'm').toDate();\n\n/**\n * Returns a new date with the minutes field replaced.\n *\n * @example\n * ```ts\n * setMinutes(new Date('2024-03-15T12:00:00'), 45);\n * ```\n */\nexport const setMinutes = (date: RawDateToFormat, minutes: number) =>\n toLibFormat(date)?.set('m', minutes).toDate();\n\n/**\n * Returns a new date with the hours field replaced.\n *\n * @example\n * ```ts\n * setHours(new Date('2024-03-15T12:00:00'), 9);\n * ```\n */\nexport const setHours = (date: RawDateToFormat, hours: number) =>\n toLibFormat(date)?.set('h', hours).toDate();\n"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;;AAAA,EAAC,SAAS,GAAE,GAAE;AAAC,cAAU,OAAO,WAAS,eAAa,OAAO,SAAO,OAAO,UAAQ,GAAG,GAAC,cAAY,OAAO,UAAQ,OAAO,MAAI,OAAO,EAAE,GAAC,CAAC,IAAE,eAAa,OAAO,aAAW,aAAW,KAAG,MAAM,wBAAsB,GAAG;cAAQ,WAAU;AAAC;EAAa,IAAI,GAAE,GAAE,IAAE,KAAI,IAAE,KAAI,IAAE,MAAK,IAAE,OAAM,IAAE,uFAAsF,IAAE,SAAQ,IAAE,QAAO,IAAE,uKAAsK,IAAE;GAAC,OAAM;GAAE,QAAO;GAAE,MAAK;GAAE,OAAM;GAAE,SAAQ;GAAE,SAAQ;GAAE,cAAa;GAAE,OAAM;GAAO,EAAC,IAAE,SAAS,GAAE;AAAC,UAAO,aAAa;KAAG,IAAE,SAAS,GAAE,GAAE,GAAE;AAAC,UAAO,IAAI,EAAE,GAAE,GAAE,EAAE,GAAG;KAAE,IAAE,SAAS,GAAE;AAAC,UAAO,EAAE,EAAE,EAAE,GAAC;KAAK,IAAE,SAAS,GAAE;AAAC,UAAO,IAAE;KAAG,IAAE,SAAS,GAAE;AAAC,UAAO,EAAE,EAAE,GAAC,KAAK,KAAK,EAAE,GAAC,KAAK,MAAM,EAAE;KAAE,IAAE,SAAS,GAAE;AAAC,UAAO,KAAK,IAAI,EAAE;KAAE,IAAE,SAAS,GAAE,GAAE;AAAC,UAAO,IAAE,EAAE,EAAE,GAAC;IAAC,UAAS,CAAC;IAAE,QAAO,KAAG,EAAE,EAAE,GAAC;IAAE,GAAC;IAAC,UAAS,CAAC;IAAE,QAAO,KAAG,IAAE;IAAE,GAAC;IAAC,UAAS,CAAC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AI,KAAK,MAAM,SAAS,GAAG,GAAG,MAAM,CAAC,EAAE,EAAE;EACvD,SAAS,KAAK,IAAI,KAAK,MAAO,SAAS,GAAG,GAAG,MAAM,GAAI,IAAK,EAAE,EAAE;EAChE,OAAO;GACL,OAAO,KAAK,MAAM,SAAS,GAAG,GAAG,OAAO,CAAC;GACzC,IAAI;GACL;EACF;;;;;;;;;;AAWH,IAAa,WAAW,MAAuB,UAC7C,YAAY,KAAK,EAAE,IAAI,OAAO,IAAI,CAAC,QAAQ;;;;;;;;;AAU7C,IAAa,gBAAgB,MAAuB,UAClD,YAAY,KAAK,EAAE,SAAS,OAAO,IAAI,CAAC,QAAQ;;;;;;;;;AAUlD,IAAa,cAAc,MAAuB,UAChD,YAAY,KAAK,EAAE,IAAI,OAAO,IAAI,CAAC,QAAQ;;;;;;;;;AAU7C,IAAa,cAAc,MAAuB,YAChD,YAAY,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,QAAQ;;;;;;;;;AAU/C,IAAa,YAAY,MAAuB,UAC9C,YAAY,KAAK,EAAE,IAAI,KAAK,MAAM,CAAC,QAAQ"}
|
|
1
|
+
{"version":3,"file":"date-time.js","names":[],"sources":["../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/plugin/duration.js","../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/plugin/relativeTime.js","../node_modules/.pnpm/dayjs@1.11.20/node_modules/dayjs/locale/ru.js","../src/date-time.ts"],"sourcesContent":["!function(t,s){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=s():\"function\"==typeof define&&define.amd?define(s):(t=\"undefined\"!=typeof globalThis?globalThis:t||self).dayjs_plugin_duration=s()}(this,(function(){\"use strict\";var t,s,n=1e3,i=6e4,e=36e5,r=864e5,o=/\\[([^\\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,u=31536e6,d=2628e6,a=/^(-|\\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,h={years:u,months:d,days:r,hours:e,minutes:i,seconds:n,milliseconds:1,weeks:6048e5},c=function(t){return t instanceof g},f=function(t,s,n){return new g(t,n,s.$l)},m=function(t){return s.p(t)+\"s\"},l=function(t){return t<0},$=function(t){return l(t)?Math.ceil(t):Math.floor(t)},y=function(t){return Math.abs(t)},v=function(t,s){return t?l(t)?{negative:!0,format:\"\"+y(t)+s}:{negative:!1,format:\"\"+t+s}:{negative:!1,format:\"\"}},g=function(){function l(t,s,n){var i=this;if(this.$d={},this.$l=n,void 0===t&&(this.$ms=0,this.parseFromMilliseconds()),s)return f(t*h[m(s)],this);if(\"number\"==typeof t)return this.$ms=t,this.parseFromMilliseconds(),this;if(\"object\"==typeof t)return Object.keys(t).forEach((function(s){i.$d[m(s)]=t[s]})),this.calMilliseconds(),this;if(\"string\"==typeof t){var e=t.match(a);if(e){var r=e.slice(2).map((function(t){return null!=t?Number(t):0}));return this.$d.years=r[0],this.$d.months=r[1],this.$d.weeks=r[2],this.$d.days=r[3],this.$d.hours=r[4],this.$d.minutes=r[5],this.$d.seconds=r[6],this.calMilliseconds(),this}}return this}var y=l.prototype;return y.calMilliseconds=function(){var t=this;this.$ms=Object.keys(this.$d).reduce((function(s,n){return s+(t.$d[n]||0)*h[n]}),0)},y.parseFromMilliseconds=function(){var t=this.$ms;this.$d.years=$(t/u),t%=u,this.$d.months=$(t/d),t%=d,this.$d.days=$(t/r),t%=r,this.$d.hours=$(t/e),t%=e,this.$d.minutes=$(t/i),t%=i,this.$d.seconds=$(t/n),t%=n,this.$d.milliseconds=t},y.toISOString=function(){var t=v(this.$d.years,\"Y\"),s=v(this.$d.months,\"M\"),n=+this.$d.days||0;this.$d.weeks&&(n+=7*this.$d.weeks);var i=v(n,\"D\"),e=v(this.$d.hours,\"H\"),r=v(this.$d.minutes,\"M\"),o=this.$d.seconds||0;this.$d.milliseconds&&(o+=this.$d.milliseconds/1e3,o=Math.round(1e3*o)/1e3);var u=v(o,\"S\"),d=t.negative||s.negative||i.negative||e.negative||r.negative||u.negative,a=e.format||r.format||u.format?\"T\":\"\",h=(d?\"-\":\"\")+\"P\"+t.format+s.format+i.format+a+e.format+r.format+u.format;return\"P\"===h||\"-P\"===h?\"P0D\":h},y.toJSON=function(){return this.toISOString()},y.format=function(t){var n=t||\"YYYY-MM-DDTHH:mm:ss\",i={Y:this.$d.years,YY:s.s(this.$d.years,2,\"0\"),YYYY:s.s(this.$d.years,4,\"0\"),M:this.$d.months,MM:s.s(this.$d.months,2,\"0\"),D:this.$d.days,DD:s.s(this.$d.days,2,\"0\"),H:this.$d.hours,HH:s.s(this.$d.hours,2,\"0\"),m:this.$d.minutes,mm:s.s(this.$d.minutes,2,\"0\"),s:this.$d.seconds,ss:s.s(this.$d.seconds,2,\"0\"),SSS:s.s(this.$d.milliseconds,3,\"0\")};return n.replace(o,(function(t,s){return s||String(i[t])}))},y.as=function(t){return this.$ms/h[m(t)]},y.get=function(t){var s=this.$ms,n=m(t);return\"milliseconds\"===n?s%=1e3:s=\"weeks\"===n?$(s/h[n]):this.$d[n],s||0},y.add=function(t,s,n){var i;return i=s?t*h[m(s)]:c(t)?t.$ms:f(t,this).$ms,f(this.$ms+i*(n?-1:1),this)},y.subtract=function(t,s){return this.add(t,s,!0)},y.locale=function(t){var s=this.clone();return s.$l=t,s},y.clone=function(){return f(this.$ms,this)},y.humanize=function(s){return t().add(this.$ms,\"ms\").locale(this.$l).fromNow(!s)},y.valueOf=function(){return this.asMilliseconds()},y.milliseconds=function(){return this.get(\"milliseconds\")},y.asMilliseconds=function(){return this.as(\"milliseconds\")},y.seconds=function(){return this.get(\"seconds\")},y.asSeconds=function(){return this.as(\"seconds\")},y.minutes=function(){return this.get(\"minutes\")},y.asMinutes=function(){return this.as(\"minutes\")},y.hours=function(){return this.get(\"hours\")},y.asHours=function(){return this.as(\"hours\")},y.days=function(){return this.get(\"days\")},y.asDays=function(){return this.as(\"days\")},y.weeks=function(){return this.get(\"weeks\")},y.asWeeks=function(){return this.as(\"weeks\")},y.months=function(){return this.get(\"months\")},y.asMonths=function(){return this.as(\"months\")},y.years=function(){return this.get(\"years\")},y.asYears=function(){return this.as(\"years\")},l}(),p=function(t,s,n){return t.add(s.years()*n,\"y\").add(s.months()*n,\"M\").add(s.days()*n,\"d\").add(s.hours()*n,\"h\").add(s.minutes()*n,\"m\").add(s.seconds()*n,\"s\").add(s.milliseconds()*n,\"ms\")};return function(n,i,e){t=e,s=e().$utils(),e.duration=function(t,s){var n=e.locale();return f(t,{$l:n},s)},e.isDuration=c;var r=i.prototype.add,o=i.prototype.subtract;i.prototype.add=function(t,s){return c(t)?p(this,t,1):r.bind(this)(t,s)},i.prototype.subtract=function(t,s){return c(t)?p(this,t,-1):o.bind(this)(t,s)}}}));","!function(r,e){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=e():\"function\"==typeof define&&define.amd?define(e):(r=\"undefined\"!=typeof globalThis?globalThis:r||self).dayjs_plugin_relativeTime=e()}(this,(function(){\"use strict\";return function(r,e,t){r=r||{};var n=e.prototype,o={future:\"in %s\",past:\"%s ago\",s:\"a few seconds\",m:\"a minute\",mm:\"%d minutes\",h:\"an hour\",hh:\"%d hours\",d:\"a day\",dd:\"%d days\",M:\"a month\",MM:\"%d months\",y:\"a year\",yy:\"%d years\"};function i(r,e,t,o){return n.fromToBase(r,e,t,o)}t.en.relativeTime=o,n.fromToBase=function(e,n,i,d,u){for(var f,a,s,l=i.$locale().relativeTime||o,h=r.thresholds||[{l:\"s\",r:44,d:\"second\"},{l:\"m\",r:89},{l:\"mm\",r:44,d:\"minute\"},{l:\"h\",r:89},{l:\"hh\",r:21,d:\"hour\"},{l:\"d\",r:35},{l:\"dd\",r:25,d:\"day\"},{l:\"M\",r:45},{l:\"MM\",r:10,d:\"month\"},{l:\"y\",r:17},{l:\"yy\",d:\"year\"}],m=h.length,c=0;c<m;c+=1){var y=h[c];y.d&&(f=d?t(e).diff(i,y.d,!0):i.diff(e,y.d,!0));var p=(r.rounding||Math.round)(Math.abs(f));if(s=f>0,p<=y.r||!y.r){p<=1&&c>0&&(y=h[c-1]);var v=l[y.l];u&&(p=u(\"\"+p)),a=\"string\"==typeof v?v.replace(\"%d\",p):v(p,n,y.l,s);break}}if(n)return a;var M=s?l.future:l.past;return\"function\"==typeof M?M(a):M.replace(\"%s\",a)},n.to=function(r,e){return i(r,e,this,!0)},n.from=function(r,e){return i(r,e,this)};var d=function(r){return r.$u?t.utc():t()};n.toNow=function(r){return this.to(d(this),r)},n.fromNow=function(r){return this.from(d(this),r)}}}));","!function(_,t){\"object\"==typeof exports&&\"undefined\"!=typeof module?module.exports=t(require(\"dayjs\")):\"function\"==typeof define&&define.amd?define([\"dayjs\"],t):(_=\"undefined\"!=typeof globalThis?globalThis:_||self).dayjs_locale_ru=t(_.dayjs)}(this,(function(_){\"use strict\";function t(_){return _&&\"object\"==typeof _&&\"default\"in _?_:{default:_}}var e=t(_),n=\"января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря\".split(\"_\"),s=\"январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь\".split(\"_\"),r=\"янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.\".split(\"_\"),o=\"янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.\".split(\"_\"),i=/D[oD]?(\\[[^[\\]]*\\]|\\s)+MMMM?/;function d(_,t,e){var n,s;return\"m\"===e?t?\"минута\":\"минуту\":_+\" \"+(n=+_,s={mm:t?\"минута_минуты_минут\":\"минуту_минуты_минут\",hh:\"час_часа_часов\",dd:\"день_дня_дней\",MM:\"месяц_месяца_месяцев\",yy:\"год_года_лет\"}[e].split(\"_\"),n%10==1&&n%100!=11?s[0]:n%10>=2&&n%10<=4&&(n%100<10||n%100>=20)?s[1]:s[2])}var u=function(_,t){return i.test(t)?n[_.month()]:s[_.month()]};u.s=s,u.f=n;var a=function(_,t){return i.test(t)?r[_.month()]:o[_.month()]};a.s=o,a.f=r;var m={name:\"ru\",weekdays:\"воскресенье_понедельник_вторник_среда_четверг_пятница_суббота\".split(\"_\"),weekdaysShort:\"вск_пнд_втр_срд_чтв_птн_сбт\".split(\"_\"),weekdaysMin:\"вс_пн_вт_ср_чт_пт_сб\".split(\"_\"),months:u,monthsShort:a,weekStart:1,yearStart:4,formats:{LT:\"H:mm\",LTS:\"H:mm:ss\",L:\"DD.MM.YYYY\",LL:\"D MMMM YYYY г.\",LLL:\"D MMMM YYYY г., H:mm\",LLLL:\"dddd, D MMMM YYYY г., H:mm\"},relativeTime:{future:\"через %s\",past:\"%s назад\",s:\"несколько секунд\",m:d,mm:d,h:\"час\",hh:d,d:\"день\",dd:d,M:\"месяц\",MM:d,y:\"год\",yy:d},ordinal:function(_){return _},meridiem:function(_){return _<4?\"ночи\":_<12?\"утра\":_<17?\"дня\":\"вечера\"}};return e.default.locale(m,null,!0),m}));","/**\n * ---header-docs-section---\n * # yummies/date-time\n *\n * ## Description\n *\n * Date and time formatting built on **dayjs** with locale plugins, human-readable presets, relative\n * phrases, and duration helpers tailored to UI copy. It composes with `yummies/format`, `yummies/ms`,\n * and `yummies/text` for declensions so timestamps read naturally in Russian-facing apps.\n *\n * ## Usage\n *\n * ```ts\n * import { formatDate } from \"yummies/date-time\";\n * ```\n */\n\nimport dayjs, { type Dayjs, type ManipulateType } from 'dayjs';\nimport duration from 'dayjs/plugin/duration.js';\nimport relativeTime from 'dayjs/plugin/relativeTime.js';\nimport { format } from 'yummies/format';\nimport { ms, unitsToMs } from 'yummies/ms';\nimport { declension } from 'yummies/text';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\nimport 'dayjs/locale/ru.js';\n\ndayjs.extend(relativeTime);\ndayjs.extend(duration);\ndayjs.locale('ru');\n\nconst toLibFormat = (value: Maybe<RawDateToFormat>): Dayjs | null => {\n let result: Maybe<Dayjs> = null;\n if (dayjs.isDayjs(value)) {\n result = value;\n } else if (value != null) {\n result = dayjs(value);\n }\n\n if (!result?.isValid()) {\n return null;\n }\n\n return result;\n};\n\nexport type RawDateToFormat = Date | string | number | Dayjs;\n\n/**\n * Formats a date-like value using predefined presets or a custom pattern.\n *\n * @example\n * ```ts\n * formatDate('2024-03-15', { format: 'time-short' });\n * ```\n */\nexport const formatDate = (\n value: Maybe<RawDateToFormat>,\n settings?: Maybe<{\n format?:\n | 'human'\n | 'full'\n | 'short'\n | 'day'\n | 'day-only'\n | 'date'\n | 'month'\n | 'spent-time'\n | 'time'\n | 'time-short';\n pattern?: string;\n asTime?: boolean;\n }>,\n) => {\n const dateFormat = settings?.format;\n const datePattern = settings?.pattern;\n const asTime = settings?.asTime;\n\n let libDate: duration.Duration | dayjs.Dayjs | null = null;\n\n if (asTime && typeGuard.isNumber(value)) {\n libDate = dayjs.duration(value);\n } else {\n libDate = toLibFormat(value);\n }\n\n if (!libDate) {\n return format.NO_VALUE;\n }\n\n if (datePattern) {\n return libDate.format(datePattern);\n }\n\n if (dateFormat === 'human' || dateFormat === 'spent-time') {\n if ('fromNow' in libDate) {\n return libDate.fromNow(dateFormat === 'spent-time');\n } else {\n return format.NO_VALUE;\n }\n }\n\n switch (dateFormat) {\n case 'full': {\n return libDate.format('DD MMM YYYY HH:mm:ss');\n }\n case 'short': {\n return libDate.format('DD MMM HH:mm');\n }\n case 'time': {\n return libDate.format('HH:mm:ss');\n }\n case 'time-short': {\n return libDate.format('HH:mm');\n }\n case 'day': {\n return libDate.format('DD MMM YYYY');\n }\n case 'month': {\n return libDate.format('MMMM YYYY');\n }\n default: {\n return libDate.format('DD.MM.YYYY');\n }\n }\n};\n\n/**\n * Splits a duration in milliseconds into day-based time parts.\n *\n * @example\n * ```ts\n * dayTimeDuration(ms(1, 'day') + ms(2, 'hour'));\n * ```\n */\nexport const dayTimeDuration = (timeInMs: number) => {\n let left = Math.max(timeInMs, 0);\n\n const days = Math.floor(left / unitsToMs.day);\n left = left % unitsToMs.day;\n\n const hours = Math.floor(left / unitsToMs.hour);\n left = left % unitsToMs.hour;\n\n const minutes = Math.floor(left / unitsToMs.min);\n left = left % unitsToMs.min;\n\n const seconds = Math.floor(left / unitsToMs.sec);\n left = left % unitsToMs.sec;\n\n const milliseconds = Math.floor(left);\n\n return {\n days,\n hours,\n minutes,\n seconds,\n milliseconds,\n };\n};\n\ntype DateChangeParam = [amount: number, unit?: Maybe<ManipulateType>];\n\n/**\n * Applies one or more date adjustments and returns a new `Date` instance.\n *\n * @example\n * ```ts\n * changeDate(new Date(), 1, 'day', 30, 'minute');\n * ```\n */\nexport const changeDate = (\n date: Maybe<RawDateToFormat>,\n ...args: [\n ...DateChangeParam,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ...Partial<DateChangeParam>,\n ]\n) => {\n let wrappedDate = toLibFormat(date)!;\n\n for (let i = 0; i < args.length; i += 2) {\n const amount = args[i] as DateChangeParam[0];\n const unit = args[i + 1] as DateChangeParam[1];\n if (unit != null) {\n wrappedDate = wrappedDate.add(amount, unit);\n }\n }\n\n return wrappedDate.toDate();\n};\n\n/**\n * Converts milliseconds into hour-based time parts without keeping full days separately.\n *\n * @example\n * ```ts\n * timeDuration(ms(1, 'hour') + ms(30, 'min'));\n * ```\n */\nexport const timeDuration = (timeInMs: number) => {\n const { days, hours, milliseconds, minutes, seconds } =\n dayTimeDuration(timeInMs);\n\n return {\n hours: hours + unitsToMs.day * days,\n milliseconds,\n minutes,\n seconds,\n };\n};\n\nconst durationFormatLabels = {\n days: { compact: 'д', full: ['день', 'дня', 'дней'] },\n hours: { compact: 'ч', full: ['час', 'часа', 'часов'] },\n minutes: { compact: 'мин', full: ['минута', 'минуты', 'минут'] },\n seconds: { compact: 'сек', full: ['секунда', 'секунды', 'секунд'] },\n} as const;\n\n/**\n * Formats a duration either from milliseconds or between two dates.\n *\n * @example\n * ```ts\n * getFormatDuration(ms(2, 'hour') + ms(15, 'min'));\n * ```\n */\nexport function getFormatDuration(\n dateA: Date,\n dateB: Date,\n compact?: boolean,\n): string;\nexport function getFormatDuration(ms: number, compact?: boolean): string;\n\nexport function getFormatDuration(...args: any[]): string {\n let compact = false;\n let diff = 0;\n\n if (args[0] instanceof Date) {\n const startedDate = dayjs(args[0]);\n const endedDate = dayjs(args[1]);\n\n diff = endedDate.diff(startedDate, 'ms');\n compact = args[2] === true;\n } else {\n diff = args[0];\n compact = args[1] === true;\n }\n\n const { days, hours, minutes, seconds } = dayTimeDuration(diff);\n\n const formattedParts: string[] = [];\n\n if (days) {\n if (compact) {\n formattedParts.push(`${days} ${durationFormatLabels.days.compact}`);\n } else {\n formattedParts.push(\n `${days} ${declension(days, durationFormatLabels.days.full)}`,\n );\n }\n }\n\n if (hours) {\n if (compact) {\n formattedParts.push(`${hours} ${durationFormatLabels.hours.compact}`);\n } else {\n formattedParts.push(\n `${hours} ${declension(hours, durationFormatLabels.hours.full)}`,\n );\n }\n }\n\n if (minutes) {\n if (compact) {\n formattedParts.push(`${minutes} ${durationFormatLabels.minutes.compact}`);\n } else {\n formattedParts.push(\n `${minutes} ${declension(minutes, durationFormatLabels.minutes.full)}`,\n );\n }\n }\n\n if (seconds) {\n if (compact) {\n formattedParts.push(`${seconds} ${durationFormatLabels.seconds.compact}`);\n } else {\n formattedParts.push(\n `${seconds} ${declension(seconds, durationFormatLabels.seconds.full)}`,\n );\n }\n }\n\n return formattedParts.join(' ');\n}\n\nexport type TimeDiff = {\n minutes: number;\n seconds: number;\n total: {\n ms: number;\n hours: number;\n };\n};\n\n/**\n * Calculates the difference between two dates in minutes, seconds and total units.\n *\n * @example\n * ```ts\n * getTimeDiff(new Date('2024-03-15T12:30:00'), new Date('2024-03-15T12:00:00'));\n * ```\n */\nexport const getTimeDiff = (\n dateA: RawDateToFormat,\n dateB: RawDateToFormat,\n): TimeDiff => {\n const leftDate = toLibFormat(dateA)?.toDate();\n const rightDate = toLibFormat(dateB)?.toDate();\n\n if (!leftDate || !rightDate) {\n return {\n minutes: 0,\n seconds: 0,\n total: { ms: 0, hours: 0 },\n };\n }\n\n const msDiff = leftDate.getTime() - rightDate.getTime();\n\n return {\n minutes: Math.max(Math.floor(msDiff / ms(1, 'min')), 0),\n seconds: Math.max(Math.floor((msDiff % ms(1, 'min')) / 1000), 0),\n total: {\n hours: Math.round(msDiff / ms(1, 'hour')),\n ms: msDiff,\n },\n };\n};\n\n/**\n * Returns a new date shifted forward by the provided number of days.\n *\n * @example\n * ```ts\n * addDays(new Date('2024-03-15'), 7);\n * ```\n */\nexport const addDays = (date: RawDateToFormat, count: number) =>\n toLibFormat(date)?.add(count, 'd').toDate();\n\n/**\n * Returns a new date shifted backward by the provided number of days.\n *\n * @example\n * ```ts\n * subtractDays(new Date('2024-03-15'), 7);\n * ```\n */\nexport const subtractDays = (date: RawDateToFormat, count: number) =>\n toLibFormat(date)?.subtract(count, 'd').toDate();\n\n/**\n * Returns a new date shifted forward by the provided number of minutes.\n *\n * @example\n * ```ts\n * addMinutes(new Date('2024-03-15T12:00:00'), 15);\n * ```\n */\nexport const addMinutes = (date: RawDateToFormat, count: number) =>\n toLibFormat(date)?.add(count, 'm').toDate();\n\n/**\n * Returns a new date with the minutes field replaced.\n *\n * @example\n * ```ts\n * setMinutes(new Date('2024-03-15T12:00:00'), 45);\n * ```\n */\nexport const setMinutes = (date: RawDateToFormat, minutes: number) =>\n toLibFormat(date)?.set('m', minutes).toDate();\n\n/**\n * Returns a new date with the hours field replaced.\n *\n * @example\n * ```ts\n * setHours(new Date('2024-03-15T12:00:00'), 9);\n * ```\n */\nexport const setHours = (date: RawDateToFormat, hours: number) =>\n toLibFormat(date)?.set('h', hours).toDate();\n"],"x_google_ignoreList":[0,1,2],"mappings":";;;;;;;;AAA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AK,MAAM,SAAS,GAAG,GAAG,OAAO,CAAC;GACzC,IAAI;GACL;EACF;;;;;;;;;;AAWH,IAAa,WAAW,MAAuB,UAC7C,YAAY,KAAK,EAAE,IAAI,OAAO,IAAI,CAAC,QAAQ;;;;;;;;;AAU7C,IAAa,gBAAgB,MAAuB,UAClD,YAAY,KAAK,EAAE,SAAS,OAAO,IAAI,CAAC,QAAQ;;;;;;;;;AAUlD,IAAa,cAAc,MAAuB,UAChD,YAAY,KAAK,EAAE,IAAI,OAAO,IAAI,CAAC,QAAQ;;;;;;;;;AAU7C,IAAa,cAAc,MAAuB,YAChD,YAAY,KAAK,EAAE,IAAI,KAAK,QAAQ,CAAC,QAAQ;;;;;;;;;AAU/C,IAAa,YAAY,MAAuB,UAC9C,YAAY,KAAK,EAAE,IAAI,KAAK,MAAM,CAAC,QAAQ"}
|
package/device.cjs
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/device.ts
|
|
3
3
|
/**
|
|
4
|
+
* ---header-docs-section---
|
|
5
|
+
* # yummies/device
|
|
6
|
+
*
|
|
7
|
+
* ## Description
|
|
8
|
+
*
|
|
9
|
+
* Lightweight user-agent sniffing for product UI: mobile/tablet heuristics and a normalized UA
|
|
10
|
+
* string accessor. These checks are best-effort (browsers spoof and evolve) and should gate only
|
|
11
|
+
* non-critical layout or analytics, never security. Prefer feature detection when the platform API
|
|
12
|
+
* is what you actually need.
|
|
13
|
+
*
|
|
14
|
+
* ## Usage
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* import { checkIsMobileDevice, getUserAgent } from "yummies/device";
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
4
21
|
* Returns the normalized user agent string in lowercase.
|
|
5
22
|
*
|
|
6
23
|
* @example
|
package/device.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.cjs","names":[],"sources":["../src/device.ts"],"sourcesContent":["/**\n * Returns the normalized user agent string in lowercase.\n *\n * @example\n * ```ts\n * const userAgent = getUserAgent();\n * ```\n */\nexport const getUserAgent = () =>\n (\n navigator.userAgent ||\n navigator.vendor ||\n // @ts-expect-error skip opera\n globalThis.opera ||\n ''\n ).toLowerCase();\n\n/**\n * Detects whether the current device should be treated as mobile based on the user agent.\n *\n * @example\n * ```ts\n * const isMobile = checkIsMobileDevice();\n * ```\n */\nexport const checkIsMobileDevice = () => {\n const userAgent = getUserAgent();\n\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(\n userAgent || '',\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(\n (userAgent || '').slice(0, 4),\n )\n ) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Detects whether the current device should be treated as a tablet based on the user agent.\n *\n * @example\n * ```ts\n * const isTablet = checkIsTabletDevice();\n * ```\n */\nexport const checkIsTabletDevice = () => {\n const userAgent = getUserAgent();\n\n return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(\n userAgent,\n );\n};\n\n/**\n * Detects whether the current device supports a touch-first form factor.\n *\n * @example\n * ```ts\n * const isTouch = checkIsTouchDevice();\n * ```\n */\nexport const checkIsTouchDevice = () =>\n checkIsMobileDevice() || checkIsTabletDevice();\n\nexport const isMobileDevice = checkIsMobileDevice();\n\nexport const isTabletDevice = checkIsTabletDevice();\n\nexport const isTouchDevice = isMobileDevice || isTabletDevice;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"device.cjs","names":[],"sources":["../src/device.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/device\n *\n * ## Description\n *\n * Lightweight user-agent sniffing for product UI: mobile/tablet heuristics and a normalized UA\n * string accessor. These checks are best-effort (browsers spoof and evolve) and should gate only\n * non-critical layout or analytics, never security. Prefer feature detection when the platform API\n * is what you actually need.\n *\n * ## Usage\n *\n * ```ts\n * import { checkIsMobileDevice, getUserAgent } from \"yummies/device\";\n * ```\n */\n\n/**\n * Returns the normalized user agent string in lowercase.\n *\n * @example\n * ```ts\n * const userAgent = getUserAgent();\n * ```\n */\nexport const getUserAgent = () =>\n (\n navigator.userAgent ||\n navigator.vendor ||\n // @ts-expect-error skip opera\n globalThis.opera ||\n ''\n ).toLowerCase();\n\n/**\n * Detects whether the current device should be treated as mobile based on the user agent.\n *\n * @example\n * ```ts\n * const isMobile = checkIsMobileDevice();\n * ```\n */\nexport const checkIsMobileDevice = () => {\n const userAgent = getUserAgent();\n\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(\n userAgent || '',\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(\n (userAgent || '').slice(0, 4),\n )\n ) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Detects whether the current device should be treated as a tablet based on the user agent.\n *\n * @example\n * ```ts\n * const isTablet = checkIsTabletDevice();\n * ```\n */\nexport const checkIsTabletDevice = () => {\n const userAgent = getUserAgent();\n\n return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(\n userAgent,\n );\n};\n\n/**\n * Detects whether the current device supports a touch-first form factor.\n *\n * @example\n * ```ts\n * const isTouch = checkIsTouchDevice();\n * ```\n */\nexport const checkIsTouchDevice = () =>\n checkIsMobileDevice() || checkIsTabletDevice();\n\nexport const isMobileDevice = checkIsMobileDevice();\n\nexport const isTabletDevice = checkIsTabletDevice();\n\nexport const isTouchDevice = isMobileDevice || isTabletDevice;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,sBAET,UAAU,aACV,UAAU,UAEV,WAAW,SACX,IACA,aAAa;;;;;;;;;AAUjB,IAAa,4BAA4B;CACvC,MAAM,YAAY,cAAc;AAEhC,KACE,2TAA2T,KACzT,aAAa,GACd,IACD,4hDAA4hD,MACzhD,aAAa,IAAI,MAAM,GAAG,EAAE,CAC9B,CAED,QAAO;AAGT,QAAO;;;;;;;;;;AAWT,IAAa,4BAA4B;CACvC,MAAM,YAAY,cAAc;AAEhC,QAAO,kHAAkH,KACvH,UACD;;;;;;;;;;AAWH,IAAa,2BACX,qBAAqB,IAAI,qBAAqB;AAEhD,IAAa,iBAAiB,qBAAqB;AAEnD,IAAa,iBAAiB,qBAAqB;AAEnD,IAAa,gBAAgB,kBAAkB"}
|
package/device.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ---header-docs-section---
|
|
3
|
+
* # yummies/device
|
|
4
|
+
*
|
|
5
|
+
* ## Description
|
|
6
|
+
*
|
|
7
|
+
* Lightweight user-agent sniffing for product UI: mobile/tablet heuristics and a normalized UA
|
|
8
|
+
* string accessor. These checks are best-effort (browsers spoof and evolve) and should gate only
|
|
9
|
+
* non-critical layout or analytics, never security. Prefer feature detection when the platform API
|
|
10
|
+
* is what you actually need.
|
|
11
|
+
*
|
|
12
|
+
* ## Usage
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { checkIsMobileDevice, getUserAgent } from "yummies/device";
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
/**
|
|
2
19
|
* Returns the normalized user agent string in lowercase.
|
|
3
20
|
*
|
package/device.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
//#region src/device.ts
|
|
2
2
|
/**
|
|
3
|
+
* ---header-docs-section---
|
|
4
|
+
* # yummies/device
|
|
5
|
+
*
|
|
6
|
+
* ## Description
|
|
7
|
+
*
|
|
8
|
+
* Lightweight user-agent sniffing for product UI: mobile/tablet heuristics and a normalized UA
|
|
9
|
+
* string accessor. These checks are best-effort (browsers spoof and evolve) and should gate only
|
|
10
|
+
* non-critical layout or analytics, never security. Prefer feature detection when the platform API
|
|
11
|
+
* is what you actually need.
|
|
12
|
+
*
|
|
13
|
+
* ## Usage
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { checkIsMobileDevice, getUserAgent } from "yummies/device";
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
3
20
|
* Returns the normalized user agent string in lowercase.
|
|
4
21
|
*
|
|
5
22
|
* @example
|
package/device.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device.js","names":[],"sources":["../src/device.ts"],"sourcesContent":["/**\n * Returns the normalized user agent string in lowercase.\n *\n * @example\n * ```ts\n * const userAgent = getUserAgent();\n * ```\n */\nexport const getUserAgent = () =>\n (\n navigator.userAgent ||\n navigator.vendor ||\n // @ts-expect-error skip opera\n globalThis.opera ||\n ''\n ).toLowerCase();\n\n/**\n * Detects whether the current device should be treated as mobile based on the user agent.\n *\n * @example\n * ```ts\n * const isMobile = checkIsMobileDevice();\n * ```\n */\nexport const checkIsMobileDevice = () => {\n const userAgent = getUserAgent();\n\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(\n userAgent || '',\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(\n (userAgent || '').slice(0, 4),\n )\n ) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Detects whether the current device should be treated as a tablet based on the user agent.\n *\n * @example\n * ```ts\n * const isTablet = checkIsTabletDevice();\n * ```\n */\nexport const checkIsTabletDevice = () => {\n const userAgent = getUserAgent();\n\n return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(\n userAgent,\n );\n};\n\n/**\n * Detects whether the current device supports a touch-first form factor.\n *\n * @example\n * ```ts\n * const isTouch = checkIsTouchDevice();\n * ```\n */\nexport const checkIsTouchDevice = () =>\n checkIsMobileDevice() || checkIsTabletDevice();\n\nexport const isMobileDevice = checkIsMobileDevice();\n\nexport const isTabletDevice = checkIsTabletDevice();\n\nexport const isTouchDevice = isMobileDevice || isTabletDevice;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"device.js","names":[],"sources":["../src/device.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/device\n *\n * ## Description\n *\n * Lightweight user-agent sniffing for product UI: mobile/tablet heuristics and a normalized UA\n * string accessor. These checks are best-effort (browsers spoof and evolve) and should gate only\n * non-critical layout or analytics, never security. Prefer feature detection when the platform API\n * is what you actually need.\n *\n * ## Usage\n *\n * ```ts\n * import { checkIsMobileDevice, getUserAgent } from \"yummies/device\";\n * ```\n */\n\n/**\n * Returns the normalized user agent string in lowercase.\n *\n * @example\n * ```ts\n * const userAgent = getUserAgent();\n * ```\n */\nexport const getUserAgent = () =>\n (\n navigator.userAgent ||\n navigator.vendor ||\n // @ts-expect-error skip opera\n globalThis.opera ||\n ''\n ).toLowerCase();\n\n/**\n * Detects whether the current device should be treated as mobile based on the user agent.\n *\n * @example\n * ```ts\n * const isMobile = checkIsMobileDevice();\n * ```\n */\nexport const checkIsMobileDevice = () => {\n const userAgent = getUserAgent();\n\n if (\n /(android|bb\\d+|meego).+mobile|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(\n userAgent || '',\n ) ||\n /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(\n (userAgent || '').slice(0, 4),\n )\n ) {\n return true;\n }\n\n return false;\n};\n\n/**\n * Detects whether the current device should be treated as a tablet based on the user agent.\n *\n * @example\n * ```ts\n * const isTablet = checkIsTabletDevice();\n * ```\n */\nexport const checkIsTabletDevice = () => {\n const userAgent = getUserAgent();\n\n return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(\n userAgent,\n );\n};\n\n/**\n * Detects whether the current device supports a touch-first form factor.\n *\n * @example\n * ```ts\n * const isTouch = checkIsTouchDevice();\n * ```\n */\nexport const checkIsTouchDevice = () =>\n checkIsMobileDevice() || checkIsTabletDevice();\n\nexport const isMobileDevice = checkIsMobileDevice();\n\nexport const isTabletDevice = checkIsTabletDevice();\n\nexport const isTouchDevice = isMobileDevice || isTabletDevice;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,IAAa,sBAET,UAAU,aACV,UAAU,UAEV,WAAW,SACX,IACA,aAAa;;;;;;;;;AAUjB,IAAa,4BAA4B;CACvC,MAAM,YAAY,cAAc;AAEhC,KACE,2TAA2T,KACzT,aAAa,GACd,IACD,4hDAA4hD,MACzhD,aAAa,IAAI,MAAM,GAAG,EAAE,CAC9B,CAED,QAAO;AAGT,QAAO;;;;;;;;;;AAWT,IAAa,4BAA4B;CACvC,MAAM,YAAY,cAAc;AAEhC,QAAO,kHAAkH,KACvH,UACD;;;;;;;;;;AAWH,IAAa,2BACX,qBAAqB,IAAI,qBAAqB;AAEhD,IAAa,iBAAiB,qBAAqB;AAEnD,IAAa,iBAAiB,qBAAqB;AAEnD,IAAa,gBAAgB,kBAAkB"}
|
package/encodings.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encodings.cjs","names":[],"sources":["../src/encodings.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/types';\n\nconst DMap: AnyObject = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n 10: 10,\n 11: 11,\n 12: 12,\n 13: 13,\n 14: 14,\n 15: 15,\n 16: 16,\n 17: 17,\n 18: 18,\n 19: 19,\n 20: 20,\n 21: 21,\n 22: 22,\n 23: 23,\n 24: 24,\n 25: 25,\n 26: 26,\n 27: 27,\n 28: 28,\n 29: 29,\n 30: 30,\n 31: 31,\n 32: 32,\n 33: 33,\n 34: 34,\n 35: 35,\n 36: 36,\n 37: 37,\n 38: 38,\n 39: 39,\n 40: 40,\n 41: 41,\n 42: 42,\n 43: 43,\n 44: 44,\n 45: 45,\n 46: 46,\n 47: 47,\n 48: 48,\n 49: 49,\n 50: 50,\n 51: 51,\n 52: 52,\n 53: 53,\n 54: 54,\n 55: 55,\n 56: 56,\n 57: 57,\n 58: 58,\n 59: 59,\n 60: 60,\n 61: 61,\n 62: 62,\n 63: 63,\n 64: 64,\n 65: 65,\n 66: 66,\n 67: 67,\n 68: 68,\n 69: 69,\n 70: 70,\n 71: 71,\n 72: 72,\n 73: 73,\n 74: 74,\n 75: 75,\n 76: 76,\n 77: 77,\n 78: 78,\n 79: 79,\n 80: 80,\n 81: 81,\n 82: 82,\n 83: 83,\n 84: 84,\n 85: 85,\n 86: 86,\n 87: 87,\n 88: 88,\n 89: 89,\n 90: 90,\n 91: 91,\n 92: 92,\n 93: 93,\n 94: 94,\n 95: 95,\n 96: 96,\n 97: 97,\n 98: 98,\n 99: 99,\n 100: 100,\n 101: 101,\n 102: 102,\n 103: 103,\n 104: 104,\n 105: 105,\n 106: 106,\n 107: 107,\n 108: 108,\n 109: 109,\n 110: 110,\n 111: 111,\n 112: 112,\n 113: 113,\n 114: 114,\n 115: 115,\n 116: 116,\n 117: 117,\n 118: 118,\n 119: 119,\n 120: 120,\n 121: 121,\n 122: 122,\n 123: 123,\n 124: 124,\n 125: 125,\n 126: 126,\n 127: 127,\n 1027: 129,\n 8225: 135,\n 1046: 198,\n 8222: 132,\n 1047: 199,\n 1168: 165,\n 1048: 200,\n 1113: 154,\n 1049: 201,\n 1045: 197,\n 1050: 202,\n 1028: 170,\n 160: 160,\n 1040: 192,\n 1051: 203,\n 164: 164,\n 166: 166,\n 167: 167,\n 169: 169,\n 171: 171,\n 172: 172,\n 173: 173,\n 174: 174,\n 1053: 205,\n 176: 176,\n 177: 177,\n 1114: 156,\n 181: 181,\n 182: 182,\n 183: 183,\n 8221: 148,\n 187: 187,\n 1029: 189,\n 1056: 208,\n 1057: 209,\n 1058: 210,\n 8364: 136,\n 1112: 188,\n 1115: 158,\n 1059: 211,\n 1060: 212,\n 1030: 178,\n 1061: 213,\n 1062: 214,\n 1063: 215,\n 1116: 157,\n 1064: 216,\n 1065: 217,\n 1031: 175,\n 1066: 218,\n 1067: 219,\n 1068: 220,\n 1069: 221,\n 1070: 222,\n 1032: 163,\n 8226: 149,\n 1071: 223,\n 1072: 224,\n 8482: 153,\n 1073: 225,\n 8240: 137,\n 1118: 162,\n 1074: 226,\n 1110: 179,\n 8230: 133,\n 1075: 227,\n 1033: 138,\n 1076: 228,\n 1077: 229,\n 8211: 150,\n 1078: 230,\n 1119: 159,\n 1079: 231,\n 1042: 194,\n 1080: 232,\n 1034: 140,\n 1025: 168,\n 1081: 233,\n 1082: 234,\n 8212: 151,\n 1083: 235,\n 1169: 180,\n 1084: 236,\n 1052: 204,\n 1085: 237,\n 1035: 142,\n 1086: 238,\n 1087: 239,\n 1088: 240,\n 1089: 241,\n 1090: 242,\n 1036: 141,\n 1041: 193,\n 1091: 243,\n 1092: 244,\n 8224: 134,\n 1093: 245,\n 8470: 185,\n 1094: 246,\n 1054: 206,\n 1095: 247,\n 1096: 248,\n 8249: 139,\n 1097: 249,\n 1098: 250,\n 1044: 196,\n 1099: 251,\n 1111: 191,\n 1055: 207,\n 1100: 252,\n 1038: 161,\n 8220: 147,\n 1101: 253,\n 8250: 155,\n 1102: 254,\n 8216: 145,\n 1103: 255,\n 1043: 195,\n 1105: 184,\n 1039: 143,\n 1026: 128,\n 1106: 144,\n 8218: 130,\n 1107: 131,\n 8217: 146,\n 1108: 186,\n 1109: 190,\n};\n\n/**\n * Converts a Unicode string into a Win-1251 encoded binary string.\n *\n * @example\n * ```ts\n * unicodeToWin1251('Привет');\n * ```\n */\nexport function unicodeToWin1251(s: string) {\n const L = [];\n for (let i = 0; i < s.length; i++) {\n const ord = s.charCodeAt(i);\n if (!(ord in DMap))\n throw new Error(`Character ${s.charAt(i)} isn't supported by win1251!`);\n L.push(String.fromCharCode(DMap[ord]));\n }\n return L.join('');\n}\n"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"encodings.cjs","names":[],"sources":["../src/encodings.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/encodings\n *\n * ## Description\n *\n * String encoding utilities such as mapping Unicode text to legacy **Windows-1251** byte\n * sequences for interoperability with older backends or binary protocols. The helpers focus on\n * explicit transforms rather than implicit `TextEncoder` defaults so you can reason about output\n * in environments where charset mistakes are costly.\n *\n * ## Usage\n *\n * ```ts\n * import { unicodeToWin1251 } from \"yummies/encodings\";\n * ```\n */\n\nimport type { AnyObject } from 'yummies/types';\n\nconst DMap: AnyObject = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n 10: 10,\n 11: 11,\n 12: 12,\n 13: 13,\n 14: 14,\n 15: 15,\n 16: 16,\n 17: 17,\n 18: 18,\n 19: 19,\n 20: 20,\n 21: 21,\n 22: 22,\n 23: 23,\n 24: 24,\n 25: 25,\n 26: 26,\n 27: 27,\n 28: 28,\n 29: 29,\n 30: 30,\n 31: 31,\n 32: 32,\n 33: 33,\n 34: 34,\n 35: 35,\n 36: 36,\n 37: 37,\n 38: 38,\n 39: 39,\n 40: 40,\n 41: 41,\n 42: 42,\n 43: 43,\n 44: 44,\n 45: 45,\n 46: 46,\n 47: 47,\n 48: 48,\n 49: 49,\n 50: 50,\n 51: 51,\n 52: 52,\n 53: 53,\n 54: 54,\n 55: 55,\n 56: 56,\n 57: 57,\n 58: 58,\n 59: 59,\n 60: 60,\n 61: 61,\n 62: 62,\n 63: 63,\n 64: 64,\n 65: 65,\n 66: 66,\n 67: 67,\n 68: 68,\n 69: 69,\n 70: 70,\n 71: 71,\n 72: 72,\n 73: 73,\n 74: 74,\n 75: 75,\n 76: 76,\n 77: 77,\n 78: 78,\n 79: 79,\n 80: 80,\n 81: 81,\n 82: 82,\n 83: 83,\n 84: 84,\n 85: 85,\n 86: 86,\n 87: 87,\n 88: 88,\n 89: 89,\n 90: 90,\n 91: 91,\n 92: 92,\n 93: 93,\n 94: 94,\n 95: 95,\n 96: 96,\n 97: 97,\n 98: 98,\n 99: 99,\n 100: 100,\n 101: 101,\n 102: 102,\n 103: 103,\n 104: 104,\n 105: 105,\n 106: 106,\n 107: 107,\n 108: 108,\n 109: 109,\n 110: 110,\n 111: 111,\n 112: 112,\n 113: 113,\n 114: 114,\n 115: 115,\n 116: 116,\n 117: 117,\n 118: 118,\n 119: 119,\n 120: 120,\n 121: 121,\n 122: 122,\n 123: 123,\n 124: 124,\n 125: 125,\n 126: 126,\n 127: 127,\n 1027: 129,\n 8225: 135,\n 1046: 198,\n 8222: 132,\n 1047: 199,\n 1168: 165,\n 1048: 200,\n 1113: 154,\n 1049: 201,\n 1045: 197,\n 1050: 202,\n 1028: 170,\n 160: 160,\n 1040: 192,\n 1051: 203,\n 164: 164,\n 166: 166,\n 167: 167,\n 169: 169,\n 171: 171,\n 172: 172,\n 173: 173,\n 174: 174,\n 1053: 205,\n 176: 176,\n 177: 177,\n 1114: 156,\n 181: 181,\n 182: 182,\n 183: 183,\n 8221: 148,\n 187: 187,\n 1029: 189,\n 1056: 208,\n 1057: 209,\n 1058: 210,\n 8364: 136,\n 1112: 188,\n 1115: 158,\n 1059: 211,\n 1060: 212,\n 1030: 178,\n 1061: 213,\n 1062: 214,\n 1063: 215,\n 1116: 157,\n 1064: 216,\n 1065: 217,\n 1031: 175,\n 1066: 218,\n 1067: 219,\n 1068: 220,\n 1069: 221,\n 1070: 222,\n 1032: 163,\n 8226: 149,\n 1071: 223,\n 1072: 224,\n 8482: 153,\n 1073: 225,\n 8240: 137,\n 1118: 162,\n 1074: 226,\n 1110: 179,\n 8230: 133,\n 1075: 227,\n 1033: 138,\n 1076: 228,\n 1077: 229,\n 8211: 150,\n 1078: 230,\n 1119: 159,\n 1079: 231,\n 1042: 194,\n 1080: 232,\n 1034: 140,\n 1025: 168,\n 1081: 233,\n 1082: 234,\n 8212: 151,\n 1083: 235,\n 1169: 180,\n 1084: 236,\n 1052: 204,\n 1085: 237,\n 1035: 142,\n 1086: 238,\n 1087: 239,\n 1088: 240,\n 1089: 241,\n 1090: 242,\n 1036: 141,\n 1041: 193,\n 1091: 243,\n 1092: 244,\n 8224: 134,\n 1093: 245,\n 8470: 185,\n 1094: 246,\n 1054: 206,\n 1095: 247,\n 1096: 248,\n 8249: 139,\n 1097: 249,\n 1098: 250,\n 1044: 196,\n 1099: 251,\n 1111: 191,\n 1055: 207,\n 1100: 252,\n 1038: 161,\n 8220: 147,\n 1101: 253,\n 8250: 155,\n 1102: 254,\n 8216: 145,\n 1103: 255,\n 1043: 195,\n 1105: 184,\n 1039: 143,\n 1026: 128,\n 1106: 144,\n 8218: 130,\n 1107: 131,\n 8217: 146,\n 1108: 186,\n 1109: 190,\n};\n\n/**\n * Converts a Unicode string into a Win-1251 encoded binary string.\n *\n * @example\n * ```ts\n * unicodeToWin1251('Привет');\n * ```\n */\nexport function unicodeToWin1251(s: string) {\n const L = [];\n for (let i = 0; i < s.length; i++) {\n const ord = s.charCodeAt(i);\n if (!(ord in DMap))\n throw new Error(`Character ${s.charAt(i)} isn't supported by win1251!`);\n L.push(String.fromCharCode(DMap[ord]));\n }\n return L.join('');\n}\n"],"mappings":";;AAoBA,IAAM,OAAkB;CACtB,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI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,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACN,MAAM;CACP;;;;;;;;;AAUD,SAAgB,iBAAiB,GAAW;CAC1C,MAAM,IAAI,EAAE;AACZ,MAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;EACjC,MAAM,MAAM,EAAE,WAAW,EAAE;AAC3B,MAAI,EAAE,OAAO,MACX,OAAM,IAAI,MAAM,aAAa,EAAE,OAAO,EAAE,CAAC,8BAA8B;AACzE,IAAE,KAAK,OAAO,aAAa,KAAK,KAAK,CAAC;;AAExC,QAAO,EAAE,KAAK,GAAG"}
|
package/encodings.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ---header-docs-section---
|
|
3
|
+
* # yummies/encodings
|
|
4
|
+
*
|
|
5
|
+
* ## Description
|
|
6
|
+
*
|
|
7
|
+
* String encoding utilities such as mapping Unicode text to legacy **Windows-1251** byte
|
|
8
|
+
* sequences for interoperability with older backends or binary protocols. The helpers focus on
|
|
9
|
+
* explicit transforms rather than implicit `TextEncoder` defaults so you can reason about output
|
|
10
|
+
* in environments where charset mistakes are costly.
|
|
11
|
+
*
|
|
12
|
+
* ## Usage
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { unicodeToWin1251 } from "yummies/encodings";
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
/**
|
|
2
19
|
* Converts a Unicode string into a Win-1251 encoded binary string.
|
|
3
20
|
*
|
package/encodings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encodings.js","names":[],"sources":["../src/encodings.ts"],"sourcesContent":["import type { AnyObject } from 'yummies/types';\n\nconst DMap: AnyObject = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n 10: 10,\n 11: 11,\n 12: 12,\n 13: 13,\n 14: 14,\n 15: 15,\n 16: 16,\n 17: 17,\n 18: 18,\n 19: 19,\n 20: 20,\n 21: 21,\n 22: 22,\n 23: 23,\n 24: 24,\n 25: 25,\n 26: 26,\n 27: 27,\n 28: 28,\n 29: 29,\n 30: 30,\n 31: 31,\n 32: 32,\n 33: 33,\n 34: 34,\n 35: 35,\n 36: 36,\n 37: 37,\n 38: 38,\n 39: 39,\n 40: 40,\n 41: 41,\n 42: 42,\n 43: 43,\n 44: 44,\n 45: 45,\n 46: 46,\n 47: 47,\n 48: 48,\n 49: 49,\n 50: 50,\n 51: 51,\n 52: 52,\n 53: 53,\n 54: 54,\n 55: 55,\n 56: 56,\n 57: 57,\n 58: 58,\n 59: 59,\n 60: 60,\n 61: 61,\n 62: 62,\n 63: 63,\n 64: 64,\n 65: 65,\n 66: 66,\n 67: 67,\n 68: 68,\n 69: 69,\n 70: 70,\n 71: 71,\n 72: 72,\n 73: 73,\n 74: 74,\n 75: 75,\n 76: 76,\n 77: 77,\n 78: 78,\n 79: 79,\n 80: 80,\n 81: 81,\n 82: 82,\n 83: 83,\n 84: 84,\n 85: 85,\n 86: 86,\n 87: 87,\n 88: 88,\n 89: 89,\n 90: 90,\n 91: 91,\n 92: 92,\n 93: 93,\n 94: 94,\n 95: 95,\n 96: 96,\n 97: 97,\n 98: 98,\n 99: 99,\n 100: 100,\n 101: 101,\n 102: 102,\n 103: 103,\n 104: 104,\n 105: 105,\n 106: 106,\n 107: 107,\n 108: 108,\n 109: 109,\n 110: 110,\n 111: 111,\n 112: 112,\n 113: 113,\n 114: 114,\n 115: 115,\n 116: 116,\n 117: 117,\n 118: 118,\n 119: 119,\n 120: 120,\n 121: 121,\n 122: 122,\n 123: 123,\n 124: 124,\n 125: 125,\n 126: 126,\n 127: 127,\n 1027: 129,\n 8225: 135,\n 1046: 198,\n 8222: 132,\n 1047: 199,\n 1168: 165,\n 1048: 200,\n 1113: 154,\n 1049: 201,\n 1045: 197,\n 1050: 202,\n 1028: 170,\n 160: 160,\n 1040: 192,\n 1051: 203,\n 164: 164,\n 166: 166,\n 167: 167,\n 169: 169,\n 171: 171,\n 172: 172,\n 173: 173,\n 174: 174,\n 1053: 205,\n 176: 176,\n 177: 177,\n 1114: 156,\n 181: 181,\n 182: 182,\n 183: 183,\n 8221: 148,\n 187: 187,\n 1029: 189,\n 1056: 208,\n 1057: 209,\n 1058: 210,\n 8364: 136,\n 1112: 188,\n 1115: 158,\n 1059: 211,\n 1060: 212,\n 1030: 178,\n 1061: 213,\n 1062: 214,\n 1063: 215,\n 1116: 157,\n 1064: 216,\n 1065: 217,\n 1031: 175,\n 1066: 218,\n 1067: 219,\n 1068: 220,\n 1069: 221,\n 1070: 222,\n 1032: 163,\n 8226: 149,\n 1071: 223,\n 1072: 224,\n 8482: 153,\n 1073: 225,\n 8240: 137,\n 1118: 162,\n 1074: 226,\n 1110: 179,\n 8230: 133,\n 1075: 227,\n 1033: 138,\n 1076: 228,\n 1077: 229,\n 8211: 150,\n 1078: 230,\n 1119: 159,\n 1079: 231,\n 1042: 194,\n 1080: 232,\n 1034: 140,\n 1025: 168,\n 1081: 233,\n 1082: 234,\n 8212: 151,\n 1083: 235,\n 1169: 180,\n 1084: 236,\n 1052: 204,\n 1085: 237,\n 1035: 142,\n 1086: 238,\n 1087: 239,\n 1088: 240,\n 1089: 241,\n 1090: 242,\n 1036: 141,\n 1041: 193,\n 1091: 243,\n 1092: 244,\n 8224: 134,\n 1093: 245,\n 8470: 185,\n 1094: 246,\n 1054: 206,\n 1095: 247,\n 1096: 248,\n 8249: 139,\n 1097: 249,\n 1098: 250,\n 1044: 196,\n 1099: 251,\n 1111: 191,\n 1055: 207,\n 1100: 252,\n 1038: 161,\n 8220: 147,\n 1101: 253,\n 8250: 155,\n 1102: 254,\n 8216: 145,\n 1103: 255,\n 1043: 195,\n 1105: 184,\n 1039: 143,\n 1026: 128,\n 1106: 144,\n 8218: 130,\n 1107: 131,\n 8217: 146,\n 1108: 186,\n 1109: 190,\n};\n\n/**\n * Converts a Unicode string into a Win-1251 encoded binary string.\n *\n * @example\n * ```ts\n * unicodeToWin1251('Привет');\n * ```\n */\nexport function unicodeToWin1251(s: string) {\n const L = [];\n for (let i = 0; i < s.length; i++) {\n const ord = s.charCodeAt(i);\n if (!(ord in DMap))\n throw new Error(`Character ${s.charAt(i)} isn't supported by win1251!`);\n L.push(String.fromCharCode(DMap[ord]));\n }\n return L.join('');\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"encodings.js","names":[],"sources":["../src/encodings.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/encodings\n *\n * ## Description\n *\n * String encoding utilities such as mapping Unicode text to legacy **Windows-1251** byte\n * sequences for interoperability with older backends or binary protocols. The helpers focus on\n * explicit transforms rather than implicit `TextEncoder` defaults so you can reason about output\n * in environments where charset mistakes are costly.\n *\n * ## Usage\n *\n * ```ts\n * import { unicodeToWin1251 } from \"yummies/encodings\";\n * ```\n */\n\nimport type { AnyObject } from 'yummies/types';\n\nconst DMap: AnyObject = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n 10: 10,\n 11: 11,\n 12: 12,\n 13: 13,\n 14: 14,\n 15: 15,\n 16: 16,\n 17: 17,\n 18: 18,\n 19: 19,\n 20: 20,\n 21: 21,\n 22: 22,\n 23: 23,\n 24: 24,\n 25: 25,\n 26: 26,\n 27: 27,\n 28: 28,\n 29: 29,\n 30: 30,\n 31: 31,\n 32: 32,\n 33: 33,\n 34: 34,\n 35: 35,\n 36: 36,\n 37: 37,\n 38: 38,\n 39: 39,\n 40: 40,\n 41: 41,\n 42: 42,\n 43: 43,\n 44: 44,\n 45: 45,\n 46: 46,\n 47: 47,\n 48: 48,\n 49: 49,\n 50: 50,\n 51: 51,\n 52: 52,\n 53: 53,\n 54: 54,\n 55: 55,\n 56: 56,\n 57: 57,\n 58: 58,\n 59: 59,\n 60: 60,\n 61: 61,\n 62: 62,\n 63: 63,\n 64: 64,\n 65: 65,\n 66: 66,\n 67: 67,\n 68: 68,\n 69: 69,\n 70: 70,\n 71: 71,\n 72: 72,\n 73: 73,\n 74: 74,\n 75: 75,\n 76: 76,\n 77: 77,\n 78: 78,\n 79: 79,\n 80: 80,\n 81: 81,\n 82: 82,\n 83: 83,\n 84: 84,\n 85: 85,\n 86: 86,\n 87: 87,\n 88: 88,\n 89: 89,\n 90: 90,\n 91: 91,\n 92: 92,\n 93: 93,\n 94: 94,\n 95: 95,\n 96: 96,\n 97: 97,\n 98: 98,\n 99: 99,\n 100: 100,\n 101: 101,\n 102: 102,\n 103: 103,\n 104: 104,\n 105: 105,\n 106: 106,\n 107: 107,\n 108: 108,\n 109: 109,\n 110: 110,\n 111: 111,\n 112: 112,\n 113: 113,\n 114: 114,\n 115: 115,\n 116: 116,\n 117: 117,\n 118: 118,\n 119: 119,\n 120: 120,\n 121: 121,\n 122: 122,\n 123: 123,\n 124: 124,\n 125: 125,\n 126: 126,\n 127: 127,\n 1027: 129,\n 8225: 135,\n 1046: 198,\n 8222: 132,\n 1047: 199,\n 1168: 165,\n 1048: 200,\n 1113: 154,\n 1049: 201,\n 1045: 197,\n 1050: 202,\n 1028: 170,\n 160: 160,\n 1040: 192,\n 1051: 203,\n 164: 164,\n 166: 166,\n 167: 167,\n 169: 169,\n 171: 171,\n 172: 172,\n 173: 173,\n 174: 174,\n 1053: 205,\n 176: 176,\n 177: 177,\n 1114: 156,\n 181: 181,\n 182: 182,\n 183: 183,\n 8221: 148,\n 187: 187,\n 1029: 189,\n 1056: 208,\n 1057: 209,\n 1058: 210,\n 8364: 136,\n 1112: 188,\n 1115: 158,\n 1059: 211,\n 1060: 212,\n 1030: 178,\n 1061: 213,\n 1062: 214,\n 1063: 215,\n 1116: 157,\n 1064: 216,\n 1065: 217,\n 1031: 175,\n 1066: 218,\n 1067: 219,\n 1068: 220,\n 1069: 221,\n 1070: 222,\n 1032: 163,\n 8226: 149,\n 1071: 223,\n 1072: 224,\n 8482: 153,\n 1073: 225,\n 8240: 137,\n 1118: 162,\n 1074: 226,\n 1110: 179,\n 8230: 133,\n 1075: 227,\n 1033: 138,\n 1076: 228,\n 1077: 229,\n 8211: 150,\n 1078: 230,\n 1119: 159,\n 1079: 231,\n 1042: 194,\n 1080: 232,\n 1034: 140,\n 1025: 168,\n 1081: 233,\n 1082: 234,\n 8212: 151,\n 1083: 235,\n 1169: 180,\n 1084: 236,\n 1052: 204,\n 1085: 237,\n 1035: 142,\n 1086: 238,\n 1087: 239,\n 1088: 240,\n 1089: 241,\n 1090: 242,\n 1036: 141,\n 1041: 193,\n 1091: 243,\n 1092: 244,\n 8224: 134,\n 1093: 245,\n 8470: 185,\n 1094: 246,\n 1054: 206,\n 1095: 247,\n 1096: 248,\n 8249: 139,\n 1097: 249,\n 1098: 250,\n 1044: 196,\n 1099: 251,\n 1111: 191,\n 1055: 207,\n 1100: 252,\n 1038: 161,\n 8220: 147,\n 1101: 253,\n 8250: 155,\n 1102: 254,\n 8216: 145,\n 1103: 255,\n 1043: 195,\n 1105: 184,\n 1039: 143,\n 1026: 128,\n 1106: 144,\n 8218: 130,\n 1107: 131,\n 8217: 146,\n 1108: 186,\n 1109: 190,\n};\n\n/**\n * Converts a Unicode string into a Win-1251 encoded binary string.\n *\n * @example\n * ```ts\n * unicodeToWin1251('Привет');\n * ```\n */\nexport function unicodeToWin1251(s: string) {\n const L = [];\n for (let i = 0; i < s.length; i++) {\n const ord = s.charCodeAt(i);\n if (!(ord in DMap))\n throw new Error(`Character ${s.charAt(i)} isn't supported by win1251!`);\n L.push(String.fromCharCode(DMap[ord]));\n }\n return L.join('');\n}\n"],"mappings":";AAoBA,IAAM,OAAkB;CACtB,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ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AK,OAAO,aAAa,KAAK,KAAK,CAAC;;AAExC,QAAO,EAAE,KAAK,GAAG"}
|
package/errors.cjs
CHANGED
|
@@ -3,6 +3,22 @@ require("./chunk-CVq3Gv4J.cjs");
|
|
|
3
3
|
let yummies_type_guard = require("yummies/type-guard");
|
|
4
4
|
//#region src/errors.ts
|
|
5
5
|
/**
|
|
6
|
+
* ---header-docs-section---
|
|
7
|
+
* # yummies/errors
|
|
8
|
+
*
|
|
9
|
+
* ## Description
|
|
10
|
+
*
|
|
11
|
+
* Turns thrown values, `Error` objects, and unknown API failures into a single human-readable string
|
|
12
|
+
* for toasts, forms, and logs. The default `getErrorText` can be extended with custom formatters and
|
|
13
|
+
* enhancers so domain-specific errors still map to stable copy without try/catch boilerplate.
|
|
14
|
+
*
|
|
15
|
+
* ## Usage
|
|
16
|
+
*
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { getErrorText } from "yummies/errors";
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
6
22
|
* Universal function for transforming any errors into readable error text
|
|
7
23
|
*
|
|
8
24
|
* This function can be enhanced with custom handlers using:
|
package/errors.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\ntype GetErrorTextEnhancer = (error: any) => string;\ntype GetErrorTextFormatErrorFn = (error: Error) => string;\n\n/**\n * Universal function for transforming any errors into readable error text\n *\n * This function can be enhanced with custom handlers using:\n * - `getErrorText.unknownErrorText`\n * - `getErrorText.formatError`\n * - `getErrorText.enhance`\n */\nexport const getErrorText = (error: unknown) => {\n if (!error) {\n return getErrorText.unknownErrorText;\n }\n\n if (typeGuard.isString(error)) {\n return error || getErrorText.unknownErrorText;\n }\n\n if (error instanceof Error) {\n return (\n (getErrorText.formatError?.(error) ?? error.message) ||\n getErrorText.unknownErrorText\n );\n }\n\n if (getErrorText.enhance) {\n return getErrorText.enhance(error) ?? getErrorText.unknownErrorText;\n } else {\n return getErrorText.unknownErrorText;\n }\n};\n\ngetErrorText.unknownErrorText = '';\ngetErrorText.formatError = null as Maybe<GetErrorTextFormatErrorFn>;\ngetErrorText.enhance = null as Maybe<GetErrorTextEnhancer>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/errors\n *\n * ## Description\n *\n * Turns thrown values, `Error` objects, and unknown API failures into a single human-readable string\n * for toasts, forms, and logs. The default `getErrorText` can be extended with custom formatters and\n * enhancers so domain-specific errors still map to stable copy without try/catch boilerplate.\n *\n * ## Usage\n *\n * ```ts\n * import { getErrorText } from \"yummies/errors\";\n * ```\n */\n\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\ntype GetErrorTextEnhancer = (error: any) => string;\ntype GetErrorTextFormatErrorFn = (error: Error) => string;\n\n/**\n * Universal function for transforming any errors into readable error text\n *\n * This function can be enhanced with custom handlers using:\n * - `getErrorText.unknownErrorText`\n * - `getErrorText.formatError`\n * - `getErrorText.enhance`\n */\nexport const getErrorText = (error: unknown) => {\n if (!error) {\n return getErrorText.unknownErrorText;\n }\n\n if (typeGuard.isString(error)) {\n return error || getErrorText.unknownErrorText;\n }\n\n if (error instanceof Error) {\n return (\n (getErrorText.formatError?.(error) ?? error.message) ||\n getErrorText.unknownErrorText\n );\n }\n\n if (getErrorText.enhance) {\n return getErrorText.enhance(error) ?? getErrorText.unknownErrorText;\n } else {\n return getErrorText.unknownErrorText;\n }\n};\n\ngetErrorText.unknownErrorText = '';\ngetErrorText.formatError = null as Maybe<GetErrorTextFormatErrorFn>;\ngetErrorText.enhance = null as Maybe<GetErrorTextEnhancer>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,gBAAgB,UAAmB;AAC9C,KAAI,CAAC,MACH,QAAO,aAAa;AAGtB,KAAI,mBAAA,UAAU,SAAS,MAAM,CAC3B,QAAO,SAAS,aAAa;AAG/B,KAAI,iBAAiB,MACnB,SACG,aAAa,cAAc,MAAM,IAAI,MAAM,YAC5C,aAAa;AAIjB,KAAI,aAAa,QACf,QAAO,aAAa,QAAQ,MAAM,IAAI,aAAa;KAEnD,QAAO,aAAa;;AAIxB,aAAa,mBAAmB;AAChC,aAAa,cAAc;AAC3B,aAAa,UAAU"}
|
package/errors.d.ts
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { Maybe } from 'yummies/types';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* ---header-docs-section---
|
|
5
|
+
* # yummies/errors
|
|
6
|
+
*
|
|
7
|
+
* ## Description
|
|
8
|
+
*
|
|
9
|
+
* Turns thrown values, `Error` objects, and unknown API failures into a single human-readable string
|
|
10
|
+
* for toasts, forms, and logs. The default `getErrorText` can be extended with custom formatters and
|
|
11
|
+
* enhancers so domain-specific errors still map to stable copy without try/catch boilerplate.
|
|
12
|
+
*
|
|
13
|
+
* ## Usage
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { getErrorText } from "yummies/errors";
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
|
|
3
20
|
type GetErrorTextEnhancer = (error: any) => string;
|
|
4
21
|
type GetErrorTextFormatErrorFn = (error: Error) => string;
|
|
5
22
|
/**
|
package/errors.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { typeGuard } from "yummies/type-guard";
|
|
2
2
|
//#region src/errors.ts
|
|
3
3
|
/**
|
|
4
|
+
* ---header-docs-section---
|
|
5
|
+
* # yummies/errors
|
|
6
|
+
*
|
|
7
|
+
* ## Description
|
|
8
|
+
*
|
|
9
|
+
* Turns thrown values, `Error` objects, and unknown API failures into a single human-readable string
|
|
10
|
+
* for toasts, forms, and logs. The default `getErrorText` can be extended with custom formatters and
|
|
11
|
+
* enhancers so domain-specific errors still map to stable copy without try/catch boilerplate.
|
|
12
|
+
*
|
|
13
|
+
* ## Usage
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { getErrorText } from "yummies/errors";
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
4
20
|
* Universal function for transforming any errors into readable error text
|
|
5
21
|
*
|
|
6
22
|
* This function can be enhanced with custom handlers using:
|
package/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["import { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\ntype GetErrorTextEnhancer = (error: any) => string;\ntype GetErrorTextFormatErrorFn = (error: Error) => string;\n\n/**\n * Universal function for transforming any errors into readable error text\n *\n * This function can be enhanced with custom handlers using:\n * - `getErrorText.unknownErrorText`\n * - `getErrorText.formatError`\n * - `getErrorText.enhance`\n */\nexport const getErrorText = (error: unknown) => {\n if (!error) {\n return getErrorText.unknownErrorText;\n }\n\n if (typeGuard.isString(error)) {\n return error || getErrorText.unknownErrorText;\n }\n\n if (error instanceof Error) {\n return (\n (getErrorText.formatError?.(error) ?? error.message) ||\n getErrorText.unknownErrorText\n );\n }\n\n if (getErrorText.enhance) {\n return getErrorText.enhance(error) ?? getErrorText.unknownErrorText;\n } else {\n return getErrorText.unknownErrorText;\n }\n};\n\ngetErrorText.unknownErrorText = '';\ngetErrorText.formatError = null as Maybe<GetErrorTextFormatErrorFn>;\ngetErrorText.enhance = null as Maybe<GetErrorTextEnhancer>;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/errors\n *\n * ## Description\n *\n * Turns thrown values, `Error` objects, and unknown API failures into a single human-readable string\n * for toasts, forms, and logs. The default `getErrorText` can be extended with custom formatters and\n * enhancers so domain-specific errors still map to stable copy without try/catch boilerplate.\n *\n * ## Usage\n *\n * ```ts\n * import { getErrorText } from \"yummies/errors\";\n * ```\n */\n\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\ntype GetErrorTextEnhancer = (error: any) => string;\ntype GetErrorTextFormatErrorFn = (error: Error) => string;\n\n/**\n * Universal function for transforming any errors into readable error text\n *\n * This function can be enhanced with custom handlers using:\n * - `getErrorText.unknownErrorText`\n * - `getErrorText.formatError`\n * - `getErrorText.enhance`\n */\nexport const getErrorText = (error: unknown) => {\n if (!error) {\n return getErrorText.unknownErrorText;\n }\n\n if (typeGuard.isString(error)) {\n return error || getErrorText.unknownErrorText;\n }\n\n if (error instanceof Error) {\n return (\n (getErrorText.formatError?.(error) ?? error.message) ||\n getErrorText.unknownErrorText\n );\n }\n\n if (getErrorText.enhance) {\n return getErrorText.enhance(error) ?? getErrorText.unknownErrorText;\n } else {\n return getErrorText.unknownErrorText;\n }\n};\n\ngetErrorText.unknownErrorText = '';\ngetErrorText.formatError = null as Maybe<GetErrorTextFormatErrorFn>;\ngetErrorText.enhance = null as Maybe<GetErrorTextEnhancer>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,IAAa,gBAAgB,UAAmB;AAC9C,KAAI,CAAC,MACH,QAAO,aAAa;AAGtB,KAAI,UAAU,SAAS,MAAM,CAC3B,QAAO,SAAS,aAAa;AAG/B,KAAI,iBAAiB,MACnB,SACG,aAAa,cAAc,MAAM,IAAI,MAAM,YAC5C,aAAa;AAIjB,KAAI,aAAa,QACf,QAAO,aAAa,QAAQ,MAAM,IAAI,aAAa;KAEnD,QAAO,aAAa;;AAIxB,aAAa,mBAAmB;AAChC,aAAa,cAAc;AAC3B,aAAa,UAAU"}
|
package/file.cjs
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/file.ts
|
|
3
3
|
/**
|
|
4
|
+
* ---header-docs-section---
|
|
5
|
+
* # yummies/file
|
|
6
|
+
*
|
|
7
|
+
* ## Description
|
|
8
|
+
*
|
|
9
|
+
* Browser `File` helpers: reading contents as Base64 data URLs or plain text with optional
|
|
10
|
+
* encoding. They wrap `FileReader` in promises so async flows stay linear and errors surface as
|
|
11
|
+
* rejections. Handy for uploads, import wizards, and client-side parsing without extra libraries.
|
|
12
|
+
*
|
|
13
|
+
* ## Usage
|
|
14
|
+
*
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { getBase64FromFile } from "yummies/file";
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
4
20
|
* Reads a file as a Base64 data URL.
|
|
5
21
|
*
|
|
6
22
|
* @example
|
package/file.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.cjs","names":[],"sources":["../src/file.ts"],"sourcesContent":["/**\n * Reads a file as a Base64 data URL.\n *\n * @example\n * ```ts\n * const value = await getBase64FromFile(file);\n * ```\n */\nexport const getBase64FromFile = (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n\n/**\n * Reads a file as text using the provided encoding.\n *\n * @example\n * ```ts\n * const text = await getTextFromFile(file, 'utf-8');\n * ```\n */\nexport const getTextFromFile = (file: File, encoding?: string) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsText(file, encoding);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.cjs","names":[],"sources":["../src/file.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/file\n *\n * ## Description\n *\n * Browser `File` helpers: reading contents as Base64 data URLs or plain text with optional\n * encoding. They wrap `FileReader` in promises so async flows stay linear and errors surface as\n * rejections. Handy for uploads, import wizards, and client-side parsing without extra libraries.\n *\n * ## Usage\n *\n * ```ts\n * import { getBase64FromFile } from \"yummies/file\";\n * ```\n */\n\n/**\n * Reads a file as a Base64 data URL.\n *\n * @example\n * ```ts\n * const value = await getBase64FromFile(file);\n * ```\n */\nexport const getBase64FromFile = (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n\n/**\n * Reads a file as text using the provided encoding.\n *\n * @example\n * ```ts\n * const text = await getTextFromFile(file, 'utf-8');\n * ```\n */\nexport const getTextFromFile = (file: File, encoding?: string) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsText(file, encoding);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,qBAAqB,SAAe;AAC/C,QAAO,IAAI,SAAiB,SAAS,WAAW;EAC9C,MAAM,SAAS,IAAI,YAAY;AAC/B,SAAO,cAAc,KAAK;AAC1B,SAAO,eAAe;AACpB,WAAQ,OAAO,OAAQ,UAAU,CAAC;;AAEpC,SAAO,WAAW,UAAU;AAC1B,UAAO,MAAM;;GAEf;;;;;;;;;;AAWJ,IAAa,mBAAmB,MAAY,aAAsB;AAChE,QAAO,IAAI,SAAiB,SAAS,WAAW;EAC9C,MAAM,SAAS,IAAI,YAAY;AAC/B,SAAO,WAAW,MAAM,SAAS;AACjC,SAAO,eAAe;AACpB,WAAQ,OAAO,OAAQ,UAAU,CAAC;;AAEpC,SAAO,WAAW,UAAU;AAC1B,UAAO,MAAM;;GAEf"}
|
package/file.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ---header-docs-section---
|
|
3
|
+
* # yummies/file
|
|
4
|
+
*
|
|
5
|
+
* ## Description
|
|
6
|
+
*
|
|
7
|
+
* Browser `File` helpers: reading contents as Base64 data URLs or plain text with optional
|
|
8
|
+
* encoding. They wrap `FileReader` in promises so async flows stay linear and errors surface as
|
|
9
|
+
* rejections. Handy for uploads, import wizards, and client-side parsing without extra libraries.
|
|
10
|
+
*
|
|
11
|
+
* ## Usage
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { getBase64FromFile } from "yummies/file";
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
1
17
|
/**
|
|
2
18
|
* Reads a file as a Base64 data URL.
|
|
3
19
|
*
|
package/file.js
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
//#region src/file.ts
|
|
2
2
|
/**
|
|
3
|
+
* ---header-docs-section---
|
|
4
|
+
* # yummies/file
|
|
5
|
+
*
|
|
6
|
+
* ## Description
|
|
7
|
+
*
|
|
8
|
+
* Browser `File` helpers: reading contents as Base64 data URLs or plain text with optional
|
|
9
|
+
* encoding. They wrap `FileReader` in promises so async flows stay linear and errors surface as
|
|
10
|
+
* rejections. Handy for uploads, import wizards, and client-side parsing without extra libraries.
|
|
11
|
+
*
|
|
12
|
+
* ## Usage
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { getBase64FromFile } from "yummies/file";
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
3
19
|
* Reads a file as a Base64 data URL.
|
|
4
20
|
*
|
|
5
21
|
* @example
|
package/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","names":[],"sources":["../src/file.ts"],"sourcesContent":["/**\n * Reads a file as a Base64 data URL.\n *\n * @example\n * ```ts\n * const value = await getBase64FromFile(file);\n * ```\n */\nexport const getBase64FromFile = (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n\n/**\n * Reads a file as text using the provided encoding.\n *\n * @example\n * ```ts\n * const text = await getTextFromFile(file, 'utf-8');\n * ```\n */\nexport const getTextFromFile = (file: File, encoding?: string) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsText(file, encoding);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"file.js","names":[],"sources":["../src/file.ts"],"sourcesContent":["/**\n * ---header-docs-section---\n * # yummies/file\n *\n * ## Description\n *\n * Browser `File` helpers: reading contents as Base64 data URLs or plain text with optional\n * encoding. They wrap `FileReader` in promises so async flows stay linear and errors surface as\n * rejections. Handy for uploads, import wizards, and client-side parsing without extra libraries.\n *\n * ## Usage\n *\n * ```ts\n * import { getBase64FromFile } from \"yummies/file\";\n * ```\n */\n\n/**\n * Reads a file as a Base64 data URL.\n *\n * @example\n * ```ts\n * const value = await getBase64FromFile(file);\n * ```\n */\nexport const getBase64FromFile = (file: File) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsDataURL(file);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n\n/**\n * Reads a file as text using the provided encoding.\n *\n * @example\n * ```ts\n * const text = await getTextFromFile(file, 'utf-8');\n * ```\n */\nexport const getTextFromFile = (file: File, encoding?: string) => {\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.readAsText(file, encoding);\n reader.onload = () => {\n resolve(reader.result!.toString());\n };\n reader.onerror = (error) => {\n reject(error);\n };\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,IAAa,qBAAqB,SAAe;AAC/C,QAAO,IAAI,SAAiB,SAAS,WAAW;EAC9C,MAAM,SAAS,IAAI,YAAY;AAC/B,SAAO,cAAc,KAAK;AAC1B,SAAO,eAAe;AACpB,WAAQ,OAAO,OAAQ,UAAU,CAAC;;AAEpC,SAAO,WAAW,UAAU;AAC1B,UAAO,MAAM;;GAEf;;;;;;;;;;AAWJ,IAAa,mBAAmB,MAAY,aAAsB;AAChE,QAAO,IAAI,SAAiB,SAAS,WAAW;EAC9C,MAAM,SAAS,IAAI,YAAY;AAC/B,SAAO,WAAW,MAAM,SAAS;AACjC,SAAO,eAAe;AACpB,WAAQ,OAAO,OAAQ,UAAU,CAAC;;AAEpC,SAAO,WAAW,UAAU;AAC1B,UAAO,MAAM;;GAEf"}
|
package/format.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.cjs","names":[],"sources":["../src/format/number.ts","../src/format/percent.ts","../src/format/skip-spaces.ts","../src/format/_exports.ts"],"sourcesContent":["import { parser } from 'yummies/parser';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\nimport { NO_VALUE } from './constants.js';\n\nexport interface NumberFormatSettings {\n delimiter?: string;\n /**\n * digitsOnlyForFloat - Show digits after decimal point only if they are not zeros after converting to number.\n * Example: \"0.00\" -> \"0\", \"0.10\" -> \"0.1\", but \"0.003\" -> \"0.003\"\n *\n * @default true\n */\n digitsOnlyForFloat?: boolean;\n /**\n * Text which will be returned if the value is undefined, null, NaN, Infinity or empty string.\n * Example: \"–\" will be returned if the value is undefined and emptyText is \"–\".\n */\n emptyText?: string;\n /**\n * Text to append to the end of the formatted number.\n * Example: if value is 1000 and postfix is \"₽\", result will be \"1 000₽\".\n */\n postfix?: string;\n /**\n * Fixed number of digits after the decimal point (number.toFixed() method)\n * If set to false, the truncation is ignored!\n */\n digits?: number | false;\n /**\n * Remove trailing zeros from the end of the number\n * Example: 0.010000000000000000000000000000000000000000000 -> 0.01\n */\n cutZeros?: boolean;\n cropDigitsOnly?: boolean;\n}\n\n/**\n * Formats a numeric value with thousands separators, fractional digit control\n * and optional postfix text.\n *\n * Invalid, empty or unsupported values fall back to `emptyText`.\n *\n * @param rawValue Number or numeric string to format.\n * @param userSettings Formatting overrides merged with `number.defaultSettings`.\n * @returns Formatted number string or fallback text.\n *\n * @example\n * ```ts\n * number(12000); // '12 000'\n * ```\n *\n * @example\n * ```ts\n * number(12.5, { digits: 1, postfix: '%' }); // '12.5%'\n * ```\n */\nexport const number = (\n rawValue: Maybe<string | number>,\n userSettings?: Maybe<NumberFormatSettings>,\n): string => {\n const settings = {\n ...number.defaultSettings,\n ...userSettings,\n };\n\n const digits = settings.digits ?? 0;\n const cutZeros = settings?.cutZeros ?? false;\n const delimiter = settings.delimiter ?? ' ';\n const postfix = settings.postfix ?? '';\n const emptyText = settings.emptyText ?? NO_VALUE;\n const digitsOnlyForFloat = settings.digitsOnlyForFloat ?? true;\n\n let value: Maybe<number>;\n\n if (typeGuard.isString(rawValue)) {\n value = parser.number(value, { fallback: undefined });\n } else {\n value = rawValue;\n }\n\n if (typeGuard.isNumber(value)) {\n let raw: string = `${value}`;\n\n if (digits !== false) {\n if (settings.cropDigitsOnly) {\n const [integerPart, decimalPart] = `${raw}`.split('.');\n const leftPart = integerPart;\n const rightPart = (decimalPart || '')\n .slice(0, digits)\n .padEnd(digits, '0');\n\n if (rightPart) {\n raw = `${leftPart}.${rightPart}`;\n } else {\n raw = leftPart;\n }\n } else {\n raw = value.toFixed(digits);\n }\n }\n\n if (cutZeros) {\n raw = `${+raw}`;\n }\n\n const [integerPart, decimalPart] = raw.split('.', 2);\n\n let formattedIntegerPart = integerPart;\n let formattedDecimalPart = '';\n\n if (decimalPart && (!digitsOnlyForFloat || !/^0+$/.test(decimalPart))) {\n formattedDecimalPart = `.${decimalPart}`;\n }\n\n const rgx = /(\\d+)(\\d{3})/;\n\n while (rgx.test(formattedIntegerPart) && delimiter) {\n formattedIntegerPart = formattedIntegerPart.replace(\n rgx,\n `$1${delimiter}$2`,\n );\n }\n\n return formattedIntegerPart + formattedDecimalPart + postfix;\n }\n\n return emptyText;\n};\n\nnumber.defaultSettings = {} as NumberFormatSettings;\n","import { parser } from 'yummies/parser';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\nimport { NO_VALUE } from './constants.js';\n\nexport interface PercentFormatSettings\n extends Omit<parser.NumberParserSettings, 'fallback'> {\n divider?: string;\n delimiter?: string;\n symbol?: string;\n emptyText?: string;\n}\n\n/**\n * Formats a value as a percent string with configurable decimal precision,\n * decimal divider and suffix symbol.\n *\n * @param value Number or numeric string to format.\n * @param settings Parser and formatting options.\n * @returns Formatted percent string or fallback text for invalid values.\n *\n * @example\n * ```ts\n * percent(12.345); // '12.35%'\n * ```\n *\n * @example\n * ```ts\n * percent(12.345, { divider: ',', symbol: ' pct' }); // '12,35 pct'\n * ```\n */\nexport const percent = (\n value: Maybe<number | string>,\n settings?: PercentFormatSettings,\n) => {\n const numericValue = parser.number(value, {\n ...settings,\n digits: settings?.digits ?? 2,\n fallback: Number.NaN,\n });\n\n if (typeGuard.isNumber(numericValue)) {\n const divider = settings?.divider ?? '.';\n\n const formattedPercent =\n divider === '.' ? numericValue : `${numericValue}`.replace('.', divider);\n\n return `${formattedPercent}${settings?.delimiter ?? ''}${settings?.symbol ?? '%'}`;\n } else {\n return settings?.emptyText ?? NO_VALUE;\n }\n};\n","/**\n * Removes all whitespace characters from a string.\n *\n * @param value Source string.\n * @returns String without spaces, tabs and line breaks.\n *\n * @example\n * ```ts\n * skipSpaces('1 000 000'); // '1000000'\n * ```\n *\n * @example\n * ```ts\n * skipSpaces('a\\tb\\nc'); // 'abc'\n * ```\n */\nexport const skipSpaces = (value: string) => value.replaceAll(/\\s/g, '');\n","export * from './constants.js';\nexport * from './number.js';\nexport * from './percent.js';\nexport * from './skip-spaces.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAa,UACX,UACA,iBACW;CACX,MAAM,WAAW;EACf,GAAG,OAAO;EACV,GAAG;EACJ;CAED,MAAM,SAAS,SAAS,UAAU;CAClC,MAAM,WAAW,U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U,WAAW;AAKrC,SAAO,GAFL,YAAY,MAAM,eAAe,GAAG,eAAe,QAAQ,KAAK,QAAQ,GAE7C,UAAU,aAAa,KAAK,UAAU,UAAU;OAE7E,QAAO,UAAU,aAAA;;;;;;;;;;;;;;;;;;;;AClCrB,IAAa,cAAc,UAAkB,MAAM,WAAW,OAAO,GAAG"}
|
|
1
|
+
{"version":3,"file":"format.cjs","names":[],"sources":["../src/format/number.ts","../src/format/percent.ts","../src/format/skip-spaces.ts","../src/format/_exports.ts"],"sourcesContent":["import { parser } from 'yummies/parser';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\nimport { NO_VALUE } from './constants.js';\n\nexport interface NumberFormatSettings {\n delimiter?: string;\n /**\n * digitsOnlyForFloat - Show digits after decimal point only if they are not zeros after converting to number.\n * Example: \"0.00\" -> \"0\", \"0.10\" -> \"0.1\", but \"0.003\" -> \"0.003\"\n *\n * @default true\n */\n digitsOnlyForFloat?: boolean;\n /**\n * Text which will be returned if the value is undefined, null, NaN, Infinity or empty string.\n * Example: \"–\" will be returned if the value is undefined and emptyText is \"–\".\n */\n emptyText?: string;\n /**\n * Text to append to the end of the formatted number.\n * Example: if value is 1000 and postfix is \"₽\", result will be \"1 000₽\".\n */\n postfix?: string;\n /**\n * Fixed number of digits after the decimal point (number.toFixed() method)\n * If set to false, the truncation is ignored!\n */\n digits?: number | false;\n /**\n * Remove trailing zeros from the end of the number\n * Example: 0.010000000000000000000000000000000000000000000 -> 0.01\n */\n cutZeros?: boolean;\n cropDigitsOnly?: boolean;\n}\n\n/**\n * Formats a numeric value with thousands separators, fractional digit control\n * and optional postfix text.\n *\n * Invalid, empty or unsupported values fall back to `emptyText`.\n *\n * @param rawValue Number or numeric string to format.\n * @param userSettings Formatting overrides merged with `number.defaultSettings`.\n * @returns Formatted number string or fallback text.\n *\n * @example\n * ```ts\n * number(12000); // '12 000'\n * ```\n *\n * @example\n * ```ts\n * number(12.5, { digits: 1, postfix: '%' }); // '12.5%'\n * ```\n */\nexport const number = (\n rawValue: Maybe<string | number>,\n userSettings?: Maybe<NumberFormatSettings>,\n): string => {\n const settings = {\n ...number.defaultSettings,\n ...userSettings,\n };\n\n const digits = settings.digits ?? 0;\n const cutZeros = settings?.cutZeros ?? false;\n const delimiter = settings.delimiter ?? ' ';\n const postfix = settings.postfix ?? '';\n const emptyText = settings.emptyText ?? NO_VALUE;\n const digitsOnlyForFloat = settings.digitsOnlyForFloat ?? true;\n\n let value: Maybe<number>;\n\n if (typeGuard.isString(rawValue)) {\n value = parser.number(value, { fallback: undefined });\n } else {\n value = rawValue;\n }\n\n if (typeGuard.isNumber(value)) {\n let raw: string = `${value}`;\n\n if (digits !== false) {\n if (settings.cropDigitsOnly) {\n const [integerPart, decimalPart] = `${raw}`.split('.');\n const leftPart = integerPart;\n const rightPart = (decimalPart || '')\n .slice(0, digits)\n .padEnd(digits, '0');\n\n if (rightPart) {\n raw = `${leftPart}.${rightPart}`;\n } else {\n raw = leftPart;\n }\n } else {\n raw = value.toFixed(digits);\n }\n }\n\n if (cutZeros) {\n raw = `${+raw}`;\n }\n\n const [integerPart, decimalPart] = raw.split('.', 2);\n\n let formattedIntegerPart = integerPart;\n let formattedDecimalPart = '';\n\n if (decimalPart && (!digitsOnlyForFloat || !/^0+$/.test(decimalPart))) {\n formattedDecimalPart = `.${decimalPart}`;\n }\n\n const rgx = /(\\d+)(\\d{3})/;\n\n while (rgx.test(formattedIntegerPart) && delimiter) {\n formattedIntegerPart = formattedIntegerPart.replace(\n rgx,\n `$1${delimiter}$2`,\n );\n }\n\n return formattedIntegerPart + formattedDecimalPart + postfix;\n }\n\n return emptyText;\n};\n\nnumber.defaultSettings = {} as NumberFormatSettings;\n","import { parser } from 'yummies/parser';\nimport { typeGuard } from 'yummies/type-guard';\nimport type { Maybe } from 'yummies/types';\n\nimport { NO_VALUE } from './constants.js';\n\nexport interface PercentFormatSettings\n extends Omit<parser.NumberParserSettings, 'fallback'> {\n divider?: string;\n delimiter?: string;\n symbol?: string;\n emptyText?: string;\n}\n\n/**\n * Formats a value as a percent string with configurable decimal precision,\n * decimal divider and suffix symbol.\n *\n * @param value Number or numeric string to format.\n * @param settings Parser and formatting options.\n * @returns Formatted percent string or fallback text for invalid values.\n *\n * @example\n * ```ts\n * percent(12.345); // '12.35%'\n * ```\n *\n * @example\n * ```ts\n * percent(12.345, { divider: ',', symbol: ' pct' }); // '12,35 pct'\n * ```\n */\nexport const percent = (\n value: Maybe<number | string>,\n settings?: PercentFormatSettings,\n) => {\n const numericValue = parser.number(value, {\n ...settings,\n digits: settings?.digits ?? 2,\n fallback: Number.NaN,\n });\n\n if (typeGuard.isNumber(numericValue)) {\n const divider = settings?.divider ?? '.';\n\n const formattedPercent =\n divider === '.' ? numericValue : `${numericValue}`.replace('.', divider);\n\n return `${formattedPercent}${settings?.delimiter ?? ''}${settings?.symbol ?? '%'}`;\n } else {\n return settings?.emptyText ?? NO_VALUE;\n }\n};\n","/**\n * Removes all whitespace characters from a string.\n *\n * @param value Source string.\n * @returns String without spaces, tabs and line breaks.\n *\n * @example\n * ```ts\n * skipSpaces('1 000 000'); // '1000000'\n * ```\n *\n * @example\n * ```ts\n * skipSpaces('a\\tb\\nc'); // 'abc'\n * ```\n */\nexport const skipSpaces = (value: string) => value.replaceAll(/\\s/g, '');\n","/**\n * ---header-docs-section---\n * # yummies/format\n *\n * ## Description\n *\n * Namespace-style **number, percent, and string** formatting for UI tables, inputs, and charts.\n * Submodules cover locale-aware numbers, percent parsing/formatting, trimming helpers, and shared\n * constants so presentation rules stay centralized and tree-shakable behind the package\n * aggregated **format** export from this entry point.\n *\n * ## Usage\n *\n * ```ts\n * import { format } from \"yummies/format\";\n * ```\n */\n\nexport * from './constants.js';\nexport * from './number.js';\nexport * from './percent.js';\nexport * from './skip-spaces.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyDA,IAAa,UACX,UACA,iBACW;CACX,MAAM,WAAW;EACf,GAAG,OAAO;EACV,GAA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