0.3.10 • Published 10 months ago

lean-wrap v0.3.10

Weekly downloads
2
License
MIT
Repository
github
Last release
10 months ago

Lean JavaScript Library

Lean is a lightweight JavaScript library that provides various utility functions and features for web development. It includes functionality for handling events, local storage, DOM manipulation, AJAX requests, and more.

Features

  • Event Handling: Lean provides event handling functions to simplify event management. It includes support for common events such as click, tap, long tap, and more.

  • Local Storage: Lean offers a simple API for working with local storage. It supports both the native localStorage API and the sqlitePlugin for SQLite-based local storage.

  • DOM Manipulation: Lean provides functions for creating and manipulating DOM elements. It allows you to set element attributes, classes, styles, and content easily.

  • AJAX Requests: Lean includes a lightweight AJAX function for making HTTP requests. It supports GET, POST, PUT, DELETE, and PATCH methods and provides options for handling query parameters, headers, and more.

For making AJAX requests in Node.js, you can use the ajax function provided by the picos-util library. The ajax function in picos-util has the same input parameters and output response format as the AJAX function in Lean.

Installation

build commands

  • ./build # compile less to css
  • ./concat < output.js > < src/dir > # combine js files to single js

To use Lean in your project, include the lean.min.js file in your HTML:

<script src="path/to/lean.min.js"></script>

Usage

Here's an example of how to use some of the features provided by Lean:

// Event Handling
document.addEventListener('click', function(event) {
  console.log('Clicked:', event.target);
});

// Local Storage
__.store('localstorage').setItem('username', 'John Doe', function(error, id) {
  if (error) {
    console.error('Error:', error);
    return;
  }
  console.log('Item saved with ID:', id);
});

__.store('localstorage').getItem('username', function(error, value) {
  if (error) {
    console.error('Error:', error);
    return;
  }
  console.log('Username:', value);
});

// DOM Manipulation
var element = __.dom.get({ tag: 'div', id: 'my-element', content: 'Hello, world!' });
document.body.appendChild(element);

// AJAX Requests
__.ajax('get', 'https://api.example.com/data', null, {}, function(error, state, responseBody, response, userData) {
	if (state !== 4) return // for response streaming
  if (error) {
    console.error('Error:', error);
    return;
  }
  console.log('Response:', responseBody);
}, userData);

Note: The above code is a minified version of Lean. It's recommended to use the unminified version during development for better readability and debugging.

Documentation

For detailed documentation and usage examples, refer to the Lean GitHub repository

License

Lean is licensed under the MIT License. See the LICENSE file for more information.

0.3.10

10 months ago

0.3.9

1 year ago

0.3.8

1 year ago

0.3.7

1 year ago

0.3.6

2 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

3 years ago

0.3.1

3 years ago

0.2.33

5 years ago

0.2.32

5 years ago

0.2.31

5 years ago

0.2.30

5 years ago

0.2.29

5 years ago

0.2.28

5 years ago

0.2.26

6 years ago

0.2.25

6 years ago

0.2.24

6 years ago

0.2.23

6 years ago

0.2.22

6 years ago

0.2.21

6 years ago

0.2.20

6 years ago

0.2.19

6 years ago

0.2.18

6 years ago

0.2.17

6 years ago

0.2.16

7 years ago

0.2.15

7 years ago

0.2.12

7 years ago

0.2.11

7 years ago

0.2.10

7 years ago

0.2.9

7 years ago

0.2.8

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago