wellwish
Version:
Generates a nuanced well-wishing phrase based on English cultural norms.
104 lines (102 loc) • 3.95 kB
JavaScript
/* *******************************************************
* wellwish
*
* @license
*
* Apache-2.0
*
* Copyright 2015-2025 Alex Stevovich
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @meta
*
* package_name: wellwish
* file_name: gen/index.cjs
* purpose: Core functionality and exports combined.
*
* @system
*
* generated_on: 2025-03-15T06:47:05.579Z
* certified_version: 1.0.0
* file_uuid: 1276971e-8a19-42c4-80dd-637a650466d9
* file_size: 3903 bytes
* file_hash: 3807254dc6f08fc584a7659a455c3cee5c53d9d14dd5051cfc71e36ea20ac496
* mast_hash: 3423ec7d7ad11dae83fd0d3cb51f27ea442005716ae8a15eefcabdc740d28f6c
* generated_by: preamble on npm!
*
* [Preamble Metadata]
********************************************************/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var index_exports = {};
__export(index_exports, {
default: () => index_default,
wellwish: () => wellwish
});
module.exports = __toCommonJS(index_exports);
var import_dayphase = __toESM(require("dayphase"), 1);
function wellwish({
day = "day",
evening = "evening",
night = "night",
dayStart = 4,
eveningStart = 17,
nightStart = 21,
hour = (/* @__PURE__ */ new Date()).getHours()
} = {}) {
const phases = [dayStart, eveningStart, nightStart].filter(
(n) => typeof n === "number" && Number.isInteger(n) && n >= 0 && n <= 24
);
if (dayStart < 0 || dayStart > 24 || !Number.isInteger(dayStart)) {
throw new Error("dayStart must be an integer between 0 and 24.");
}
if (eveningStart < 0 || eveningStart > 24 || !Number.isInteger(eveningStart)) {
throw new Error("eveningStart must be an integer between 0 and 24.");
}
if (nightStart < 0 || nightStart > 24 || !Number.isInteger(nightStart)) {
throw new Error("nightStart must be an integer between 0 and 24.");
}
const phaseIndex = (0, import_dayphase.default)(phases, hour);
return [night, day, evening][phaseIndex] || night;
}
var index_default = wellwish;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
wellwish
});