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

rastjs-app

v1.0.0

Published

<table align="center"><tr><td align="center" width="9999"> <img src="https://drive.google.com/uc?export=view&id=1kybX7EAbhNyDJN03ORD82tpvThHwJch5" height="150" align='center' />

Downloads

1

Readme

RastJS

JavaScript front-end library that supports concurrent mode

  • RastJS provides a Virtual DOM abstraction on top of the actual DOM and it's fast, thanks to a simple and predictable reconcile algorithm implementation.
  • Like react, when a component's state data changes, the rendered elements in the DOM will be updated.

Installation

npm install -g rastjs-app
  • Note: When you generate a rasp-app, rastjs core library is already installed. it also includes webpack and babel (Like create-react-app).

Here is the link to core library repository: https://github.com/iamwendellbalagot/rastjs

  • To create a RastJS app, on your terminal use:
rast-app your-app-name
  • To start the development server:
npm start
  • Bundling rasp-app:
  • Note: css and sass loaders are already installed, you can also use custom loaders by modifying the webpack.config.js
npm run build

Usage

import Rast, { initializeValue, DOMnode } from "rastjs";
/** @jsx DOMnode */

const App = () => {
  return (
    <div>
      <h1>Hello World</h1>
    </div>
  );
};

export default App;
  • Note: you need to add //* @jsx DOMnode*/ to every .js files that uses JSX to transpile it (see the example above).

Known Issue

When you use ternary operators or (map/forEach) to render JSX elements, you need to put a div element as a wrapper.

//Example 1
<div>{myState.value? <p>Hello, World</p> : null}</div>
//Example 2
<div>{mystate.value.map(item => (<p>{item}</p>))}</div>

initializeValue Hook

Like react, you can also declare a state in your application using RastJS.

//State Implementation
import {DOMnode, initializeValue} from 'rastjs';
/** @jsx DOMnode */
const App = () => {
  const myState = initializeValue('value'); // Initialize a state
  
  const handleState = () => {
    //Change the state value
    myInput.setValue('new value');
    //You can get the value of a certain state by using:
    console.log(myState.value);
  }
  
  return;
}
export default App;

initializeEffect Hook

import {DOMnode, initializeValue, initializeEffect} from 'rastjs';
/** @jsx DOMnode */ 

const App = () => {
  const myState = initializeValue('value'); // Initialize a state
  
  //Initialize an effect that runs whenever the **myState** value changes.
  initializeEffect([myState.value], () => {
    console.log(`myState value UPDATED to ${myState.value}`)
  });
  
  const handleState = () => {
    //Change the state value
    myInput.setValue('new value');
    //You can get the value of a certain state by using:
    console.log(myState.value);
  }
  
  return;
}
export default App;

CSS & SCSS usage

CSS & SASS loaders are already installed and configured. You can modify the webpack.config.js to add custom loaders.

  • There are two ways to import CSS and SCSS files.
//import the css or scss file
import './styles.css'

...
// Assign a class on a element.
<div className='app'>
  <p>Hello, World</p>
</div>
//import the css or scss file
import styles from './styles.css'

...
// Assign a class on a element.
<div className={styles.app}>
  <p>Hello, World</p>
</div>

Inline Styling

Use camel-casing, do not use (background-color) when declaring a style, rast will complain.

<div style={{backgroundColor: 'steelblue'}}>
  <p>Hello, World</p>
</div>

Event Listeners

When adding an event listener on a certain element, use event + event-name (example: eventClick). Here is the link of available DOM element events: https://www.w3schools.com/jsref/dom_obj_event.asp

<button eventClick={your_function} >Add</button>
<input eventInput={(e) => myState.setValue(e.target.value)} />
<form eventSubmit={handleSubmit}></form>

Importing images

use:

//Assuming that the image is on the assets folder
import yourImage from '../assets/your-image.png';
<img src={yourImage} />

//DO NOT USE THIS:
<img src='../assets/your-image.png' />
//If you use this kind of syntax, webpack will not include the image when you bundle the app.

License

This repo is under the MIT license.