UNPKG

@ingestkorea/client-sens

Version:

INGESTKOREA SDK Naver Cloud Platform SENS Client for Node.js.

32 lines (31 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getRequestDuration = exports.getContentLength = exports.prettyPhoneNum = exports.trimText = exports.MMS_FILE_MAX = exports.LMS_MAX = exports.SMS_MAX = void 0; exports.SMS_MAX = 90; exports.LMS_MAX = 2000; exports.MMS_FILE_MAX = 300; // KiByte const trimText = (input) => input.trim(); exports.trimText = trimText; const prettyPhoneNum = (input) => input.replace(/\-/gi, ""); exports.prettyPhoneNum = prettyPhoneNum; /** @returns content-length(euc-kr) */ const getContentLength = (input) => { return input.split("").reduce((acc, text) => { let byte = Buffer.from(text).length; let modulo = byte % 3; modulo ? (acc += 1) : (acc += 2); return acc; }, 0); }; exports.getContentLength = getContentLength; const getRequestDuration = (input) => { const OFFSET = 9 * 60 * 60 * 1000; const hours = input ? Math.abs(input) : 24; const hours_ms = hours * 60 * 60 * 1000; const current_ms = new Date().getTime() + OFFSET; const startTime_ms = current_ms - hours_ms; let current_kst = new Date(current_ms).toISOString().replace(/\.\d{3}Z$/, ""); let startTime_kst = new Date(startTime_ms).toISOString().replace(/\.\d{3}Z$/, ""); return { startTime: startTime_kst, endTime: current_kst }; }; exports.getRequestDuration = getRequestDuration;