Skip to content

AfaanBilal/pulsejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pulse

Ask DeepWiki

NPM Minified Size Minified + GZipped

Author: Afaan Bilal

Introduction

Pulse is a JavaScript library for building reactive stuff.

Demo

A very minimal demo can be found here with the associated source code here.

A slightly less minimal demo can be found here with the associated source code here.

Installation

npm i @afaanbilal/pulse

Example usage

import { createMonitor, createPulse } from "@afaanbilal/pulse";

const [count, setCount] = createPulse(0);

const h1 = document.createElement("h1");
createMonitor(() => h1.innerText = `Count is ${count()}`);

const btn = document.createElement("button");
createMonitor(() => btn.innerText = `Increment (To: ${count() + 1})`);
btn.onclick = () => setCount(count() + 1);

const btnDouble = document.createElement("button");
createMonitor(() => btnDouble.innerText = `Double (To: ${count() * 2})`);
btnDouble.onclick = () => setCount(count() * 2);

document.body.append(h1, btn, btnDouble);

Creating a new project

  1. Create a new Vite project by (choose Vanilla with/without Typescript):
npm create vite@latest
  1. Install Pulse
npm i @afaanbilal/pulse
  1. Follow the example usage above.

  2. Start

npm run dev

Testing

npm test
> @afaanbilal/pulse@0.0.3 test
> jest --coverage

 PASS  test/index.test.ts
  √ should create a pulse (1 ms)
  √ should update a pulse
  √ should create a monitor

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |     100 |      100 |     100 |     100 |
 index.ts |     100 |      100 |     100 |     100 |
----------|---------|----------|---------|---------|-------------------
Test Suites: 1 passed, 1 total
Tests:       3 passed, 3 total
Snapshots:   0 total
Time:        0.56 s, estimated 1 s
Ran all test suites.

Contributing

All contributions are welcome. Please create an issue first for any feature request or bug. Then fork the repository, create a branch and make any changes to fix the bug or add the feature and create a pull request. That's it! Thanks!

License

Pulse is released under the MIT License. Check out the full license here.

About

PulseJS - experimental reactivity

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors