Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@l8js/l8

l8js1.1kMIT0.12.1

Lightweight core library for JavaScript projects

l8

readme

@l8js/l8 MIT npm version build

l8.js (Read: light js)

Site | Twitter

Lightweight JavaScript library.
Skipping bold abstraction layers for the sake of a more lean approach towards functional programming.

l8js is released under the MIT license & supports modern environments.

Why l8.js?

l8.js provides functionality, wrappers and thin(!) abstraction layers to ease the process of accessing and manipulating data in JavaScript. It also provides syntactical sugar for convenient access to language specific functions.


    // create object based on null object
    let obj = l8.obj();
    obj.key = "value";
    obj instanceof Object; // false

    // l8.chain
    let obj = {};
    l8.chain("a.b.c.d", obj, "foo"); // obj is { a : { b : {c : { d : "foo"}}}}


    // l8.visit
    let visitor = (value, path) => {
        return `${path.join(".")}=${value}`;
    };
    let tree = {
        node : {
            node_1 : "a"
        }
    };
    tree = l8.visit(tree, visitor);
    expect(tree.node.node_1).toBe("node.node_1=a");


    // l8.replace
    let str = l8.replace(["foo", "bar"], ["oof", "rab"], "this foo is bar"); // this oof is rab
    str = l8.replace(["A", "B"], ["B", "D"], "A"); // D
    str = l8.replace(["A", "C"], "B", "AC"); // BB
    str = l8.replace(["A", "C"], ["B"], "AC"); // B
    str = l8.replace("A", "B", "A"); // B    


    // l8.unify
    let str = l8.unify("https:///HOST///api/endpoint//", "/", "://");
    console.log(str); // https://HOST/api/endpoint/"


    // l8.groupIndices
    var list   = ['4', 5, '1', '3', 6, '8'];
    l8.groupIndices(list); // [[1], [3, 4, 5, 6], [8]]


    // l8.liquify - fluent async interfaces with the liquify proxy  
    const source = {
        foo : async function () { return this; },
        bar : async function () { return this; },
        snafu : async function () { return "snafu"; }
    };
    await l8.liquify(source).foo().bar().snafu();


    // l8.load
    const text = await l8.load("./README.md");
    console.log(res); // response text


    // l8.ping - sends HEAD to resource
    const exists = await l8.ping("./README.md");
    console.log(exists); // true or false


    // l8.text.toHyperlink - l8.text provides parser-/transformation-utilities 
    const html = l8.text.toHyperlink("This is an url https://www.conjoon.org and it is not clickable");
    console.log(html); // This is an url <a href="https://www.conjoon.org">https://www.conjoon.org</a> and it is not clickable


    // l8.template.esix.StringTemplate - Template Engine supporting ES6 Templates-Strings.
    let tpl = l8.template.esix.make("This is a ${templated} string ${that.supports} JavaScript TemplateStrings");
    console.log(tpl.render({templated : "parsed", that : {supports : "that supports"}}));
    // This is a parsed string that supports JavaScript TemplateStrings

    // l8.md5() - create MD5-Hash from String
    let hashed = l8.md5("demo@conjoon.org")

    let name = l8.text.nameToOrdinal("New Folder", ["New Folder (1)", "users", "randomName"]);
    console.log(name); // "New Folder (2)"

    // ... and many more

Installation

Using npm:

$ npm i @l8js/l8

Running Tests and using Build Scripts

$ npm run build:dev

for installing dev-dependencies. This allows for running tests and build-scripts. The script will also install necessary git hooks.

Usage

Builds can be found in ./dist/. API docs are available in ./docs.
Note: Minimized and none-minimized builds are available. None-minimized can be identified by ".debug." in their file-name (e.g. sourcefile.debug.js vs sourcefile.js).

Module Formats

Default JS Module export

Provides default JS-Module export for the whole l8.js-library.

import l8 from "./dist/l8.runtime.esm.js";

Named JS module exports

Provides named JS-Module exports for the main-packages of l8.js-library.

import {core, template, text} from "./dist/l8.packages.esm.js";

Universal Module Definition (UMD)

Provides a Universal Module Definition for the whole l8.js-library.

<script type="text/javascript" src="./dist/l8.runtime.umd.js" />

3rd-party Acknowledgements

l8.js uses crypto-js for l8.md5().

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

0.12.1 (2023-03-08)

Bug Fixes

  • information in arrays containing chains are lost (da6ea74)

0.12.0 (2023-03-08)

Features

  • unchain() digests array of chain nodes for unchaining target object (1f5ce40)

0.11.0 (2023-03-08)

Features

  • chain() digests array of array for building target chains (0e7df1e)

0.10.2 (2023-02-26)

Bug Fixes

  • replacement token in replace() are target of replacement (15bba4e)

0.10.1 (2022-12-28)

Bug Fixes

0.10.0 (2022-12-28)

Features

0.9.0 (2022-12-24)

Features

  • add nameToOrdinal() for computing name w/ ordinal (9651ed7)

0.8.0 (2022-12-12)

Features

  • allow for specific separator in l8.unchain (4ace40c)

0.7.4 (2022-06-04)

0.7.3 (2022-06-04)

Bug Fixes

  • unify appends ignore tokens where it shouldn't (28c0feb)

0.7.2 (2022-05-14)

Bug Fixes

  • add file extension for crypot-js/md5 in import (9412ed6)

0.7.1 (2022-05-14)

Bug Fixes

  • external dependency crypto-js must be part of dependencies (c95fe2d)

0.7.0 (2022-05-14)

Bug Fixes

  • call to "preversion"-script needs to include "npm run" (d33e2ca)

0.6.1 (2022-05-08)

0.6.0 (2022-05-05)

Features

0.5.6 (2022-04-22)

Bug Fixes

  • l8.load does not throw error if resource was not found (49bf801), closes l8js/l8#31

0.5.5 (2021-11-19)

Bug Fixes

0.5.4 (2021-11-09)

Features

  • add l8.obj() for creating objects based on null object (144600a)

0.5.3 (2021-10-14)

Features

  • add extract to array-module (07ae577)

Bug Fixes

  • subsequent pre-commit hooks execute if the previous succeeds (64ef822)

0.5.2 (2021-10-07)

0.5.1 (2021-10-07)

0.5.0 (2021-10-06)

    • enhancement: added jest-fetch-mock for mocking fetch() (185bdb4)
    • enhancement: added make() for StringTemplate (9de8e4b)
    • enhancement: added optional third argument to unify() for excluding specific patterns from unifyin (73673d3)
    • enhancement: added refactorings of transformer classes (49ecf6f)
    • enhancement: added testcase for unify (31c4a5f)
    • enhancement: added tests for core/request (c4ad63f)
    • enhancement: codeCoverage disabled (c9abc36)
    • enhancement: refactored FileLoader into functional entities (cc96fe8)
    • enhancement: refactored transformers into functional entities (3117fd5)
    • enhancement: updated docs (3e2d359)
    • enhancement: updated module exports (a6726e1)
    • fixed: fixed an issue where the target string would need sanitizing before considering tokens to i (a4b5f65)
    • fixed: fixed an issue where unify could be called with empty string for token to unify (818e1be)
  • 0.5.0 (2c6e3b0)

0.4.2 (2021-09-28)

0.4.1 (2021-09-28)

0.4.0 (2021-09-28)

0.3.9 (2021-09-27)

    • fixed: removed prepare in favor of postinstall (830e82d)
  • 0.3.9 (1bdcdff)

0.3.8 (2021-09-27)

0.3.7 (2021-09-27)

0.3.6 (2021-09-27)

0.3.5 (2021-09-27)

0.3.4 (2021-09-27)

0.3.3 (2021-09-26)

    • draft: workflow changes (5096cbc)
    • draft: workflow changes (9628b97)
    • enhancement: added "override" option to chain() (47c2957)
    • enhancement: added assign() to assign specific key/values from one object to another (f507ecc)
    • enhancement: added code coverage and API doc generation, updated docs, removed aliases (15fce25)
    • enhancement: added dist postionstall, changed object.visit() so that the path is returned as an ar (8550e17)
    • enhancement: added findFirst() (d627838)
    • enhancement: added isNot (4a1c541)
    • enhancement: added isPlainObject/isRegExp (19efd4f)
    • enhancement: functionality improvements (ea0329b)
    • enhancement: housekeeping, added workflows (9c3f623)
    • enhancement: migrated lib-cn_core-templates to l8.js (d0ce63e)
    • enhancement: migrated text.transformer.html from lib-cn_core into l8, minor file-naming changes (27e644d)
    • enhancement: minor code layout updates, removed doc fragments (36cbb61)
    • enhancement: minor doc updates (da91dfe)
    • enhancement: namespacing, file renaming, added various methods, FileLoader (cadace3)
    • enhancement: package organization changes, functionality tweaks (be034fc)
    • enhancement: package updates (95152ae)
    • enhancement: project setup enhancements (3a8e0a0)
    • enhancement: removed webpack-dependencies, added rollup (cdb23de)
    • enhancement: tagged 0.2.0 (7f884c0)
    • enhancement: updated dependencies (4ef8694)
    • enhancement: updated eslint config, added pre-commit hook (9354703)
    • enhancement: workflow changes (f050f2c)
    • enhancement: workflow enhancements (4fe1c5f)
    • enhancement: workflow fixes (7a5b495)
    • enhancement: workflow updates (6ace67c)
    • enhancement: workflow updates (377eb89)
    • enhancement: workflow updates (2900e3a)
    • enhancement: workflow updates (babffeb)
    • enhancement: workflow updates (cec184f)
    • enhancement: workflow updates (c5de113)
    • fixed: fixed an issue where the tests for FileLoader would not properly consider asynchronous cont (fe4be5c)
  • 0.2.6 (720ca31)
  • 0.2.7 (db4ede4)
  • 0.2.8 (6de083c)
  • 0.2.8 (83fd7b7)
  • 0.2.9 (67a752e)
  • 0.3.0 (bd5bd60)
  • 0.3.1 (f9e255c)
  • 0.3.1 (8701565)
  • 0.3.2 (765fdbe)
  • 0.3.3 (6a13468)
  • initial commit (ebe37a5)
  • Initial commit (840b261)