All Projects â†’ argyleink â†’ blingblingjs

argyleink / blingblingjs

Licence: MIT License
💲 Micro-library of shorthands for DOM selection, events, and attribute manipulation

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to blingblingjs

LetsGitHubSearch
Let'Swift 18 Workshop - Let's TDD
Stars: ✭ 60 (-63.41%)
Mutual labels:  tdd
clean-ts-api
API em NodeJs usando Typescript, TDD, Clean Architecture, Design Patterns e SOLID principles
Stars: ✭ 43 (-73.78%)
Mutual labels:  tdd
pycrunch-engine
NCrunch inspired tool for continuous testing Python
Stars: ✭ 38 (-76.83%)
Mutual labels:  tdd
npm-es-modules
Breakdown of 7 different ways to use ES modules with npm today.
Stars: ✭ 67 (-59.15%)
Mutual labels:  commonjs
apple-mango
Python BDD Pattern
Stars: ✭ 18 (-89.02%)
Mutual labels:  tdd
WSHModule
WSHModule is a JavaScript virtual machine built in WSH/JScript.
Stars: ✭ 28 (-82.93%)
Mutual labels:  commonjs
Glize
📚 Glize is a clean and robust pure Javascript library.
Stars: ✭ 16 (-90.24%)
Mutual labels:  dom-manipulation
dirname-filename-esm
__dirname and __filename for ES Modules environment
Stars: ✭ 57 (-65.24%)
Mutual labels:  commonjs
CtCI-with-Ruby-TDD
Cracking the Coding Interview with Ruby and TDD
Stars: ✭ 44 (-73.17%)
Mutual labels:  tdd
specific
Generate mocks and other test doubles using clojure.spec
Stars: ✭ 31 (-81.1%)
Mutual labels:  tdd
TddCourse
Kod źródłowy do kursu TDD na blogu dariuszwozniak.NET.
Stars: ✭ 18 (-89.02%)
Mutual labels:  tdd
mpx-es-check
Checks the version of ES in JavaScript files with simple shell commands
Stars: ✭ 15 (-90.85%)
Mutual labels:  commonjs
estj
EstJ is my own test framework!
Stars: ✭ 13 (-92.07%)
Mutual labels:  tdd
tdd roman csharp
Kata: TDD Arabic to Roman Numerals with C#
Stars: ✭ 14 (-91.46%)
Mutual labels:  tdd
cart
Domain-Driven Design shop cart demonstration
Stars: ✭ 80 (-51.22%)
Mutual labels:  tdd
curso-javascript-testes
Código-fonte do curso "Aprenda a testar Aplicações Javascript"
Stars: ✭ 60 (-63.41%)
Mutual labels:  tdd
MarvelBrowser-Swift
Swift TDD Sample App
Stars: ✭ 31 (-81.1%)
Mutual labels:  tdd
katas
TypeScript Katas to practice TDD and programming
Stars: ✭ 90 (-45.12%)
Mutual labels:  tdd
symfony-prooph-example
prooph in symfony example
Stars: ✭ 19 (-88.41%)
Mutual labels:  tdd
mock-spy-module-import
JavaScript import/require module testing do's and don'ts with Jest
Stars: ✭ 40 (-75.61%)
Mutual labels:  commonjs

BlingBlingJS

Build Status Total Downloads Latest Release License

like bling.js, but more bling


Getting Started

Installation

npm i blingblingjs

Importing

// import the blingbling y'all
import $ from 'blingblingjs'                // es6 module
const $ = require('blingblingjs')           // commonjs

// or from Pika CDN! https://cdn.pika.dev/blingblingjs/v2

Syntax

Quick Overview

$()        // select nodes in document or pass nodes in
$().on     // add multiple event listeners to multiple nodes
$().off    // remove multiple event listeners from multiple nodes
$().attr   // CRUD attributes on nodes
$().map    // use native array methods

Queries

// get nodes from the document
const btns         = $('button')            // blingbling always returns an array
const [first_btn]  = $('button[primary]')   // destructure shortcut for 1st/only match
const btn_spans    = $('span', btns)        // provide a query context by passing a 2nd param of node/nodes

// cover DOM nodes in bling
const [sugared_single]  = $(document.querySelector('button'))
const sugared_buttons   = $(document.querySelectorAll('button'))

Array Methods

$('button').forEach(...)
$('button').map(...)

const btns = $('button')
btns.filter(...)
btns.reduce(...)
btns.flatMap(...)
...

Events

// single events
first_btn.on('click', ({target}) => console.log(target))
$('button[primary]').on('click', e => console.log(e))

// single events with options
first_btn.on('click', ({target}) => console.log(target), {once: true})
$('button[primary]').on('click', e => console.log(e), true) // useCapture

// multiple events
$('h1').on('click touchend', ({target}) => console.log(target))

// remove events
const log_event = e => console.warn(e) // must have a reference to the original function
main_btn.on('contextmenu', log_event)
main_btn.off('contextmenu', log_event)

Attributes

// set an attribute
$('button.rad').attr('rad', true)

// set multiple attributes
const [rad_btn] = $('button.rad')
rad_btn.attr({
  test: 'foo',
  hi:   'bye',
})

// get an attribute
rad_btn.attr('rad')        // "true"
rad_btn.attr('hi')         // "bye"

// get multiple attributes
$('button').map(btn => ({
  tests:  btn.attr('tests'),
  hi:     btn.attr('hi'),
}))

// remove an attribute
rad_btn.attr('hi', null)   // set to null to remove
rad_btn.attr('hi')         // attribute not found

// remove multiple attributes
btns.attr({
  test:   null,
  hi:     null,
})

Convenience

import {rIC, rAF} from 'blingblingjs'

// requestAnimationFrame
rAF(_ => {
  // animation tick
})

// requestIdleCallback
rIC(_ => {
  // good time to compute
})


What for?

Developer ergonomics! If you agree with any of the following, you may appreciate this micro library:

  • Love vanilla js, want to keep your code close to it
  • Chaining is fun, Arrays are fun, essentially a functional programming fan
  • Hate typing document.querySelector over.. and over..
  • Hate typing addEventListener over.. and over..
  • Really wish document.querySelectorAll had array methods on it..
  • Confused that there is no node.setAttributes({...}) or even better nodeList.setAttributes({...})
  • Liked jQuery selector syntax
Why BlingBling?
  • Minimal at 0.6kb (636 bytes)
  • BlingBling supports ES6 module importing and common module loading
  • Supports chaining
  • Worth it's weight (should save more characters than it loads)
  • Only enhances the nodes you query with it
  • ES6 version of popular bling.js by Paul Irish
  • Tested
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].