npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lopos

v0.0.3

Published

Lopos is like a clone of if() but with more options, also there is a test command allows you to test anything ugh idk.

Readme

lopos

Lopos is a powerful utility library for advanced conditional testing, flexible date handling, deep merging, throttling, cloning, and conditional logic — all packed with extensive options and without relying on native if statements in some parts.

Ideal for developers who want flexible, readable, and highly customizable utility functions in JavaScript.


Website


Installation

npm install lopos

Importing

const { 
  test, 
  lopif, 
  deepMerge, 
  flexibleDate, 
  advancedThrottle, 
  deepClone 
} = require("lopos");

Functions

test(type, actual, expected, options)

Flexible test function for many types of comparisons and validations, including deep equality, string checks, array contents, regex, async functions, and custom predicates.

  • type: String key defining the test type.
  • actual: Value to test.
  • expected: Value or parameter used in the test.
  • options: Optional flags such as ignoreCase, tolerance, or deep for customizing behavior.
  • returns: boolean result of the test.

Example:

test("equals", 5, 5); // true
test("contains", "Hello World", "world", { ignoreCase: true }); // true
test("inRange", 10, [5, 15]); // true

lopif(condition, onTrue, onFalse, options)

Conditional execution mimicking if-else logic without using if statements. Supports chained conditions, hooks before and after execution, and flexible handlers.

  • condition: Boolean or truthy/falsy value.
  • onTrue/onFalse: Values or functions executed based on condition.
  • options: Optional hooks (pre, post) and chaining of multiple conditionals.
  • returns: Result of executed handler or fallback.

Example:

lopif(
  10 > 5, 
  () => "Yes", 
  () => "No", 
  { pre: cond => console.log("Checking:", cond), post: res => console.log("Result:", res) }
);
// Logs: Checking: true
// Logs: Result: Yes
// Returns: "Yes"

deepMerge(...sources, options)

Deeply merges multiple objects or arrays with customizable behavior such as array concatenation, cloning, and custom merge strategies.

  • sources: Two or more objects or arrays.
  • options: Controls like arrayConcat, clone, and customizer function.
  • returns: A new deeply merged object or array.

Example:

deepMerge(
  { a: 1, b: { c: 2 } }, 
  { b: { d: 3 }, e: 4 }, 
  { arrayConcat: false }
);
// Result: { a: 1, b: { c: 2, d: 3 }, e: 4 }

flexibleDate(input, options)

Parse, validate, adjust, and format dates flexibly. Supports strings, timestamps, Date objects, relative time, timezone offsets, strict mode, and custom output formatting.

  • input: Date input (string, number, Date, null).
  • options: Settings like format, strict, fallback, timezone, relative, adjustDays.
  • returns: Formatted date string, timestamp, Date object, or fallback.

Example:

flexibleDate("2023-01-01T12:00:00Z", { format: "locale", timezone: "utc" });
// Might return: "1/1/2023, 12:00:00 PM"

flexibleDate(null, { fallback: "Invalid Date" });
// Returns: "Invalid Date"

advancedThrottle(func, delay, options)

Throttle a function with advanced controls like leading/trailing call, max call limits, cancellation, and flushing.

  • func: Function to throttle.
  • delay: Delay in milliseconds.
  • options: leading, trailing, maxCalls.
  • returns: Throttled function with cancel and flush methods.

Example:

const throttled = advancedThrottle(() => console.log("Called!"), 1000, { leading: true });
throttled();
throttled.cancel();
throttled.flush();

deepClone(value)

Deeply clones any value including complex types like objects, arrays, maps, sets, dates, regexps, with support for circular references.

  • value: Any JavaScript value to clone.
  • returns: Deep cloned copy of the value.

Example:

const obj = { a: 1, b: { c: 2 } };
const clone = deepClone(obj);
clone.b.c = 3;
console.log(obj.b.c); // 2 (original unchanged)

Made with ❤️ for developers who want advanced, clean, and expressive utility functions in JavaScript.

Feel free to contribute or open issues!