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

lambda-bag

v0.0.15

Published

Functional utility toolbelt for vanillaJS

Downloads

47

Readme

Lambda Bag MIT Licence PRs Welcome npm version CircleCI

Introduction

Functional JavaScript utility library focused in performance, modularity, and functional pattern.

The idea of this project is a lightweight set of functions the will reduce the amount of code in your vanilla JS project

Basically you won't need any library or be attached to one framework instead of that this compile some partterns that are commonly used in different projects following the DRY approach focusing in functional programming

You'll have some parts of jQuery, loadash, angular, react and other libraries

Installation

npm install lambda-bag

Usage

Documentation

Browser API

This module creates an API for common Browser API using simplified and friendly syntax (Similar to JQuery). It can be combined with observers, functional operators & helpers included below

// Don't do this 
const view = document.querySelector("[view]")
const modal = document.querySelector("[modal]")

if (view.classList.contains("active")) {
  view.classList.remove("hide")
} else {
  view.classList.add("hide")
}

// Do this
import { toggleAttr, select } from 'lambda-bag/lib/query'
const view = select('[view]')
const modal = select('[modal]')
toggleAttr(view,'hide')
toggleAttr(modal,'hide')

View all

Functional Operators

import { pipe, map, add } from 'lambda-bag/lib/operators'

const double = (x) => x * 2
// Compose multiplication and sum in the respective order
pipe(
  map(double),
  map(add(3))
)([1,2,3,4,-1,0]) 

View all operators

Observers API

import { Observer } from 'lambda-bag/lib/observers'
const AppState = State; 

// Initialize subject
const firstSubject = { 
  data: 'value-1', 
  ...Observer((data)=>{
    console.log(`subcription #1 ${data}`)
  })
}

// or
const secondSubject = { 
  other: 'value-2' ,   
  update(data) {
    console.log('subcription #2', data)
  }
}

// Hydrate state with initial users.
AppState.update({ foo: 'bar' });
AppState.addObserver(firstSubject);
AppState.addObserver(secondSubject);

// Get application state
AppState.get()

// Update application state and remove observer
AppState.update({ x: 'New Value' })
AppState.removeObserver(secondSubject);

View documentation

Helpers

import { toggleElem, rmQueryParam, setQueryParam } from 'lambda-bag/lib/general'
const key = 'option'
const value = 'param1'
const params  = 'param1 param2 param3'
const switchAttrs = toggleElem(value)(params) // Toggle string value ' param2 param3'
switchAttrs.length <= 0 ? 
  rmQueryParam(key) : 
  setQueryParam(key, switchAttrs.join(','))

View all helpers

Contributing

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

License

Lambda Bag is MIT licensed.