Files
docx-js/src/util/convenience-functions.ts

13 lines
436 B
TypeScript
Raw Normal View History

import { nanoid } from "nanoid/non-secure";
2021-03-12 03:58:05 +00:00
let currentCount = 0;
2021-03-12 03:58:05 +00:00
2020-12-24 03:37:43 +00:00
// Twip - twentieths of a point
2022-08-31 07:52:27 +01:00
export const convertMillimetersToTwip = (millimeters: number): number => Math.floor((millimeters / 25.4) * 72 * 20);
2020-12-24 03:37:43 +00:00
2022-08-31 07:52:27 +01:00
export const convertInchesToTwip = (inches: number): number => Math.floor(inches * 72 * 20);
2021-03-12 03:58:05 +00:00
2022-08-31 08:59:27 +01:00
export const uniqueNumericId = (): number => ++currentCount;
2021-03-12 03:58:05 +00:00
2022-08-31 07:52:27 +01:00
export const uniqueId = (): string => nanoid().toLowerCase();