@aligent/utils

1.1.4 • Public • Published

Aligent JS Utility Functions

A general purpose library to be used for generic functions around manipulating data.

Dependencies on Axios and Lodash.

Install

npm install @aligent/utils

Ajax Class

A small wrapper around axios.

Use case

import { Ajax } from '@aligent/utils';

const myAjaxRequest = new Ajax();

/**
 * Perform a POST request
 *
 * @param {string} url        URL to send the POST request to
 * @param {object} data       Data to be POSTed to the server with the request
 * @param {object} additional [Optional] Additional params, data, headers to be attached to request
 *
 * @returns {Promise}
 */
await myAjaxRequest.post(url, data, additional)

Can also use .get(), .put(), .delete() the same way.

Translator Class

A way to fetch the translation map object

Use

import { Translator, __ } from '@aligent/utils';

// fire ajax to file
Translator.init('/path-to-translation-file');

// translate string - will return same string if not found.
__('My Cart') //=> eg Bag

Storage Class

localStorage abstraction wrapped in Promises.

Use:

import { Storage } from '@aligent/utils';

await Storage.setItem('mykey', 'myvalue');
await Storage.getItem('mykey');
await Storage.removeItem('mykey');

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.1.4
    118
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.1.4
    118
  • 1.1.3
    0
  • 1.1.1
    38
  • 1.1.0
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i @aligent/utils

Weekly Downloads

156

Version

1.1.4

License

MIT

Unpacked Size

140 kB

Total Files

168

Last publish

Collaborators

  • torbjorn.vanheeswijck
  • aligent-bot
  • aligent-danielvanderploeg
  • luke-denton-aligent
  • jarrod.swift