Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,297 changes: 879 additions & 418 deletions API.md

Large diffs are not rendered by default.

715 changes: 715 additions & 0 deletions dist/index.d.mts

Large diffs are not rendered by default.

715 changes: 715 additions & 0 deletions dist/index.d.ts

Large diffs are not rendered by default.

3,381 changes: 3,381 additions & 0 deletions dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.js.map

Large diffs are not rendered by default.

3,361 changes: 3,361 additions & 0 deletions dist/index.mjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/index.mjs.map

Large diffs are not rendered by default.

721 changes: 0 additions & 721 deletions dist/numfmt.d.ts

This file was deleted.

2 changes: 0 additions & 2 deletions dist/numfmt.js

This file was deleted.

14 changes: 7 additions & 7 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export default tseslint.config(
files: [
'**/*.js',
'**/*.ts',
'**/*.mjs',
'**/*.mjs'
],
ignores: [
'dist/*',
'dist/*'
],
languageOptions: {
globals: { ...globals.browser },
parserOptions: { projectService: { allowDefaultProject: [] } },
},
parserOptions: { projectService: { allowDefaultProject: [] } }
}
},
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
Expand All @@ -25,7 +25,7 @@ export default tseslint.config(
borgarLint.config.stylistic({
commaDangle: false,
singleBlocks: true,
lineLength: 120,
lineLength: 120
}),
{
rules: {
Expand All @@ -34,6 +34,6 @@ export default tseslint.config(
'@typescript-eslint/no-unsafe-call': 'off',
// rule is currently bugged
'no-useless-assignment': 'off'
},
},
}
}
);
8 changes: 0 additions & 8 deletions lib/clamp.js

This file was deleted.

8 changes: 8 additions & 0 deletions lib/clamp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function clamp (num: number): number {
if (num === 0) {
return num;
}
const d = Math.ceil(Math.log10(num < 0 ? -num : num));
const mag = 10 ** (16 - Math.floor(d));
return isFinite(mag) ? Math.round(num * mag) / mag : 0;
}
2 changes: 1 addition & 1 deletion lib/codeToLocale.js → lib/codeToLocale.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @stylistic/indent */
// https://docs.microsoft.com/en-us/office/vba/api/office.msolanguageid
export default Object.freeze({
export const codeToLocale: Readonly<Record<number, string>> = Object.freeze({
1078: 'af', // Afrikaans
1052: 'sq', // Albanian
1118: 'am', // Amharic
Expand Down
148 changes: 0 additions & 148 deletions lib/constants.js

This file was deleted.

173 changes: 173 additions & 0 deletions lib/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
export const u_YEAR = 2;
export const u_MONTH = 2 ** 2;
export const u_DAY = 2 ** 3;
export const u_HOUR = 2 ** 4;
export const u_MIN = 2 ** 5;
export const u_SEC = 2 ** 6;
export const u_DSEC = 2 ** 7; // decisecond
export const u_CSEC = 2 ** 8; // centisecond
export const u_MSEC = 2 ** 9; // millisecond

// Excel date boundaries
export const MIN_S_DATE = 0;
export const MAX_S_DATE = 2958466;
// Google date boundaries
export const MIN_L_DATE = -694324;
export const MAX_L_DATE = 35830291;

// if more calendars are added, they should conform to MS CALID identifiers
// https://docs.microsoft.com/en-us/windows/win32/intl/calendar-identifiers
export const EPOCH_1904 = -1;
export const EPOCH_1900 = 1;
export const EPOCH_1317 = 6;

export const TOKEN_GENERAL = 'GENERAL';
export const TOKEN_HASH = 'HASH';
export const TOKEN_ZERO = 'ZERO';
export const TOKEN_QMARK = 'QMARK';
export const TOKEN_SLASH = 'SLASH';
export const TOKEN_GROUP = 'GROUP';
export const TOKEN_SCALE = 'SCALE';
export const TOKEN_COMMA = 'COMMA';
export const TOKEN_BREAK = 'BREAK';
export const TOKEN_TEXT = 'TEXT';
export const TOKEN_PLUS = 'PLUS';
export const TOKEN_MINUS = 'MINUS';
export const TOKEN_POINT = 'POINT';
export const TOKEN_SPACE = 'SPACE';
export const TOKEN_PERCENT = 'PERCENT';
export const TOKEN_DIGIT = 'DIGIT';
export const TOKEN_CALENDAR = 'CALENDAR';
export const TOKEN_ERROR = 'ERROR';
export const TOKEN_DATETIME = 'DATETIME';
export const TOKEN_DURATION = 'DURATION';
export const TOKEN_CONDITION = 'CONDITION';
export const TOKEN_DBNUM = 'DBNUM';
export const TOKEN_NATNUM = 'NATNUM';
export const TOKEN_LOCALE = 'LOCALE';
export const TOKEN_COLOR = 'COLOR';
export const TOKEN_MODIFIER = 'MODIFIER';
export const TOKEN_AMPM = 'AMPM';
export const TOKEN_ESCAPED = 'ESCAPED';
export const TOKEN_STRING = 'STRING';
export const TOKEN_SKIP = 'SKIP';
export const TOKEN_EXP = 'EXP';
export const TOKEN_FILL = 'FILL';
export const TOKEN_PAREN = 'PAREN';
export const TOKEN_CHAR = 'CHAR';

export const T_TYPE_INT = 'INT';
export const T_TYPE_NUM = 'NUM';
export const T_TYPE_MAN = 'MAN';
export const T_TYPE_DEN = 'DEN';
export const T_TYPE_FRAC = 'FRAC';
export const T_TYPE_DIV = 'DIV';
export const T_TYPE_YEAR = 'YEAR';
export const T_TYPE_YEAR_S = 'YEAR-SHORT';
export const T_TYPE_MON = 'MONTH';
export const T_TYPE_MNAME_1 = 'MONTHNAME-SINGLE';
export const T_TYPE_MNAME_S = 'MONTHNAME-SHORT';
export const T_TYPE_MNAME = 'MONTHNAME';
export const T_TYPE_WEEKDAY_S = 'WEEKDAY-SHORT';
export const T_TYPE_WEEKDAY = 'WEEKDAY';
export const T_TYPE_DAY = 'DAY';
export const T_TYPE_HOUR = 'HOUR';
export const T_TYPE_MIN = 'MIN';
export const T_TYPE_SEC = 'SEC';
export const T_TYPE_SUBSEC = 'SUBSEC';
export const T_TYPE_HOUR_E = 'HOUR-ELAP';
export const T_TYPE_MIN_E = 'MIN-ELAP';
export const T_TYPE_SEC_E = 'SEC-ELAP';
export const T_TYPE_B_YEAR = 'B-YEAR';
export const T_TYPE_B_YEAR_S = 'B-YEAR-SHORT';

export const indexColors = [
'#000000',
'#FFFFFF',
'#FF0000',
'#00FF00',
'#0000FF',
'#FFFF00',
'#FF00FF',
'#00FFFF',
'#800000',
'#008000',
'#000080',
'#808000',
'#800080',
'#008080',
'#C0C0C0',
'#808080',
'#9999FF',
'#993366',
'#FFFFCC',
'#CCFFFF',
'#660066',
'#FF8080',
'#0066CC',
'#CCCCFF',
'#000080',
'#FF00FF',
'#FFFF00',
'#00FFFF',
'#800080',
'#800000',
'#008080',
'#0000FF',
'#00CCFF',
'#CCFFFF',
'#CCFFCC',
'#FFFF99',
'#99CCFF',
'#FF99CC',
'#CC99FF',
'#FFCC99',
'#3366FF',
'#33CCCC',
'#99CC00',
'#FFCC00',
'#FF9900',
'#FF6600',
'#666699',
'#969696',
'#003366',
'#339966',
'#003300',
'#333300',
'#993300',
'#993366',
'#333399',
'#333333'
];

export const currencySymbols = [
'¤',
'$',
'£',
'¥',
'֏',
'؋',
'৳',
'฿',
'៛',
'₡',
'₦',
'₩',
'₪',
'₫',
'€',
'₭',
'₮',
'₱',
'₲',
'₴',
'₸',
'₹',
'₺',
'₼',
'₽',
'₾',
'₿'
];

export const reCurrencySymbols = new RegExp('[' + currencySymbols.join('') + ']');
Loading