@aligent/utils

1.1.7 • 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');

Readme

Keywords

Package Sidebar

Install

npm i @aligent/utils

Weekly Downloads

251

Version

1.1.7

License

MIT

Unpacked Size

52.7 kB

Total Files

75

Last publish

Collaborators

  • sam.tyler
  • torbjorn.vanheeswijck
  • aligent-bot
  • aligent-danielvanderploeg
  • jarrod.swift