@aegis-framework/artemis

0.3.29 • Public • Published

Artemis

Artemis is a JavaScript Library that aims to provide common utilities needed during development such as DOM manipulation, a wrapper for client based Storage and other functions that may be useful for web app development.

Using it

Artemis is provided as a CommonJS, ES6 and global library.

Browser

<script src='./artemis.min.js'></script>
const { $_, Text } = Artemis;

ES6 Modules

import { $_, Text } from '@aegis-framework/artemis';

Node JS

const { $_, Text } = require ('@aegis-framework/artemis');

Below are some simple examples but you can read the full documentation of each class for more details.

Classes

DOM

Artemis core library focuses on DOM manipulation, providing a jQuery-like experience and API

$_ready (()=> {
	$_('body').append ('<h1>Some Title</h1>');
    $_('h1').text ('A different title');
    $_('h1').style ('color', '#424242');
});

Form

Artemis also includes a small form utility class that helps with filling and retrieving values from a form.

<form data-form="MyForm">
	<input type="text" name="SomeInput">
	<input type="text" name="OtherInput">
</form>
Form.fill ('MyForm', {
	'SomeInput': 'Here is some Value',
    'OtherInput': 'And here’s another one'
});

console.log (Form.values ('MyForm'));

Space

The Space Library is a wrapper for simple storage solutions as Local and Session storage but provides data independence through storage namespaces and versioning.

let space = new Space (SpaceAdapter.LocalStorage, {
	name: 'Storage',
	version: '0.1.0'
});

space.set ('Test', {
    value: 'Some Value'
}).then (({key, value}) => {
    console.log ('The value was inserted correctly!');
});

space.get ('Test').then ((value) => {
    return value;
}).then (({key, value}) => {
    console.log (value);
});

space = new Space (SpaceAdapter.LocalStorage, {
	name: 'Storage',
	version: '0.1.1'
});

space.upgrade ('0.1.0', '0.1.1', (storage) => {
    return storage.set ('Test', {
		value: 'Other Value'
	});
});

Request

The request library provides a simple way to send HTTP requests using the fetch API.

Request.get ('https://example.com/api/', {
	'someQueryParam': 'Some Query Value!'
}).then ((response) => {
	return response.text ();
}).then ((text) => {
	console.log (text);
});

Request.post ('https://example.com/api/', {
	'someKey': 'Some Value!'
}).then ((response) => {
	return response.text ();
}).then ((text) => {
	console.log (text);
});

Platform

The platform library provides several utility methods to obtain information about the platform in which the code is running.

if (Platform.mobile ('Android')) {
	console.log ('You are running this on Android!');
} else if (Platform.mobile ()) {
	console.log ('You are running this on some kind of mobile device!');
} else if (Platform.desktop ('macOS')) {
	console.log ('You are running this on a Mac!');
}

if (Platform.electron ()) {
	console.log ('You are running this on a Electron!');
} else if (Platform.cordova ()) {
	console.log ('You are running this on a Cordova!');
}

Text

The text library provides simple utility methods to perform text transformations or other text related functions.

console.log (Text.capitalize ('is this text capitalized?'));
// Logs: Is This Text Capitalized?

console.log (Text.suffix ('Hello', 'Hello how are you?'));
// Logs: how are you?

console.log (Text.prefix ('how are you?', 'Hello how are you?'));
// Logs: Hello

Util

The util library provides diverse methods that could be useful for some applications

console.log (Util.uuid ());
// Logs: Some UUID such as 116a7d96-8c6c-46ee-a9e1-3c7183e691b5

function test () {
	console.log ('A simple Function');
}

Util.callAsync (test).then (() => {
	console.log ('Test was executed and a promise was inserted so test behaves like a function using promises');
});

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.3.296latest

Version History

VersionDownloads (Last 7 Days)Published
0.3.296
0.3.280
0.3.270
0.3.261
0.3.250
0.3.241
0.3.232
0.3.221
0.3.210
0.3.201
0.3.191
0.3.181
0.3.170
0.3.160
0.3.150
0.3.141
0.3.130
0.3.120
0.3.110
0.3.101
0.3.90
0.3.81
0.3.70
0.3.60
0.3.51
0.3.41
0.3.30
0.3.20
0.3.11
0.3.00
0.2.81
0.2.70
0.2.61
0.2.50
0.2.40
0.2.30
0.2.20
0.2.11
0.2.00

Package Sidebar

Install

npm i @aegis-framework/artemis

Weekly Downloads

21

Version

0.3.29

License

MIT

Unpacked Size

637 kB

Total Files

24

Last publish

Collaborators

  • hyuchia