UNPKG

gmail-mbox-stats

Version:
64 lines (60 loc) 2.48 kB
"use strict"; /* process.argv looks liek this: [ 'C:\\Program Files\\nodejs\\node.exe', 'C:\\Users\\leodevbroUser\\AppData\\Local\\npm-cache\\_npx\\6b3a38aa2be73d0e\\node_modules\\gmail-mbox-stats\\bin.js', 'enbbbb= qqq kkkk' ] */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.countOccurrences = exports.getSlimDateTime = exports.waitSomeSeconds = void 0; const waitSomeSeconds = (seconds) => __awaiter(void 0, void 0, void 0, function* () { const smartPromise = new Promise((resolve) => { setTimeout(() => { resolve(true); }, seconds * 1000); }); return smartPromise; }); exports.waitSomeSeconds = waitSomeSeconds; const getSlimDateTime = (myDate) => { const newDate = myDate; const localDT = { year: newDate.getFullYear(), month: newDate.getMonth() + 1, monthDay: newDate.getDate(), // hour: newDate.getHours(), minute: newDate.getMinutes(), seconds: newDate.getSeconds(), }; const eachStr = { year: String(localDT.year), month: String(localDT.month).padStart(2, "0"), monthDay: String(localDT.monthDay).padStart(2, "0"), // hour: String(localDT.hour).padStart(2, "0"), minute: String(localDT.minute).padStart(2, "0"), seconds: String(localDT.seconds).padStart(2, "0"), }; const str = `${eachStr.year}-${eachStr.month}-${eachStr.monthDay}_${eachStr.hour}-${eachStr.minute}-${eachStr.seconds}`; return str; }; exports.getSlimDateTime = getSlimDateTime; // not yet used const countOccurrences = (fullStr, partStr) => { const regExp = new RegExp(partStr, "g"); const count = (fullStr.match(regExp) || []).length; return count; }; exports.countOccurrences = countOccurrences;