npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lean-wrap

v0.3.10

Published

javascript browser utilities

Downloads

6

Readme

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.