GitHub

Changelog

Track the evolution of Lopos with detailed version history and new features.

Changelog
Version History
Updates
lopos v0.0.2
Latest

Added Functions

Core Functions

test(type, actual, expected, options)

A flexible validation function supporting type checks, deep equality, comparisons, and custom logic.

test("equals", { a: 1 }, { a: 1 }, { deep: true }); // true
test("inRange", 5, [1, 10]); // true
test("regexTest", "hello123", /\d+$/); // true
lopif(condition, onTrue, onFalse, options)

Conditional execution logic without if statements, supporting chaining and hooks.

lopif(
  true,
  () => "yes",
  () => "no",
  {
    chain: [
      { cond: false, onTrue: "chain-true" },
      { cond: true, onTrue: () => "fallback-true", onFalse: "fallback-false" }
    ]
  }
); // "fallback-true"
deepMerge(...objects, options)

Deep merge utility for objects and arrays with cloning and customizer support.

deepMerge(
  { a: 1, b: { x: 10 } },
  { b: { y: 20 }, c: 3 },
  { arrayConcat: false }
);
// { a: 1, b: { x: 10, y: 20 }, c: 3 }
flexibleDate(input, options)

Smart date parser and formatter with timezone, format, and fallback support.

flexibleDate("2024-01-01", { format: "timestamp" }); // 1704067200000
flexibleDate("invalid", { fallback: "N/A" }); // "N/A"
advancedThrottle(func, delay, options)

Throttle function with leading/trailing options and cancellation.

const throttled = advancedThrottle(console.log, 1000);
throttled("hello");
throttled.cancel();
deepClone(value)

Performs deep cloning, including circular structures and special types.

const original = { a: 1, b: { c: 2 } };
const copy = deepClone(original);

Utility Functions

smartMap(array, mapper, options)

Async-aware map with concurrency control and filtering.

await smartMap([1, 2, 3], async x => x * 2);
// [2, 4, 6]
objectDiff(obj1, obj2, options)

Finds differences between two objects with optional depth.

objectDiff({ a: 1, b: 2 }, { a: 1, b: 3 });
// { b: { from: 2, to: 3 } }
flattenObject(obj)

Flattens nested objects into dot notation keys.

flattenObject({ a: { b: 1, c: { d: 2 } } });
// { "a.b": 1, "a.c.d": 2 }
groupBy(array, keyFn)

Groups array items by a provided function.

groupBy([{ type: "fruit" }, { type: "veg" }], x => x.type);
// { fruit: [...], veg: [...] }
smartTemplate(template, data, options)

Mini template engine with support for fallbacks, conditionals, and async.

await smartTemplate("Hello {{name}}", { name: "Alice" });
// "Hello Alice"
What's Next?

We're continuously working on improving Lopos with new features and optimizations. Stay tuned for:

  • Performance optimizations for large datasets
  • Additional utility functions based on community feedback
  • TypeScript definitions for better development experience
  • Browser compatibility improvements
  • More comprehensive examples and use cases