All Projects → myWsq → processor

myWsq / processor

Licence: other
A simple and lightweight JavaScript data processing tool. Live demo:

Programming Languages

typescript
32286 projects
Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to processor

vesselize
⛵ A JavaScript IoC container that works seamlessly with Vue.js and React.
Stars: ✭ 22 (-18.52%)
Mutual labels:  react-hooks, vue-composition-api
veact
Mutable state enhancer library for React based on @vuejs
Stars: ✭ 62 (+129.63%)
Mutual labels:  react-hooks, vue-composition-api
hodux
🚀Simple reactive React Hooks state management.
Stars: ✭ 29 (+7.41%)
Mutual labels:  react-hooks
React-Netflix-Clone
A Fully Responsive clone of Netflix website built using React.JS as a Front-end & Firebase as a Back-end.
Stars: ✭ 91 (+237.04%)
Mutual labels:  react-hooks
react-stateful
A simple implementation of React-State-Hook and React-Effect-Hook to show how React-Hooks work
Stars: ✭ 34 (+25.93%)
Mutual labels:  react-hooks
promotion-web
基于React: v18.x.x/Webpack: v5.x.x/React Router v6.x.x/ Antd: v5..x.x/Fetch Api/ Typescript: v4.x.x 等最新版本进行构建...
Stars: ✭ 374 (+1285.19%)
Mutual labels:  react-hooks
etl
[READ-ONLY] PHP - ETL (Extract Transform Load) data processing library
Stars: ✭ 279 (+933.33%)
Mutual labels:  data-processing
flutter use
Play Flutter Hooks.
Stars: ✭ 150 (+455.56%)
Mutual labels:  react-hooks
react-sage
Handy-dandy React hooks.
Stars: ✭ 21 (-22.22%)
Mutual labels:  react-hooks
processor
A compiler, assembler, and processor.
Stars: ✭ 24 (-11.11%)
Mutual labels:  processor
device-orientation
React hook for the Device Orientation API
Stars: ✭ 23 (-14.81%)
Mutual labels:  react-hooks
web
React hooks done right, for browser and SSR.
Stars: ✭ 940 (+3381.48%)
Mutual labels:  react-hooks
vue-virtualised
Blazing fast scrolling and updating for any amount of list and hierarchical data.
Stars: ✭ 18 (-33.33%)
Mutual labels:  vue-composition-api
next-qrcode
React hooks for generating QRCode for your next React apps.
Stars: ✭ 87 (+222.22%)
Mutual labels:  react-hooks
awesome-web-react
🚀 Awesome Web Based React 🚀 Develop online with React!
Stars: ✭ 31 (+14.81%)
Mutual labels:  react-hooks
MonsterJS
MonsterJS - a game for learning JavaScript DOM Selectors while playing!
Stars: ✭ 26 (-3.7%)
Mutual labels:  react-hooks
covid-19-stats
Get the latest COVID-19 statistics by country
Stars: ✭ 41 (+51.85%)
Mutual labels:  react-hooks
Forum-App-React-Frontend
This is the React client that consumes the API built here: https://github.com/victorsteven/Forum-App-Go-Backend
Stars: ✭ 39 (+44.44%)
Mutual labels:  react-hooks
react-use-hubspot-form
Embed HubSpot forms into your React components using hooks! Works with Create React App, Gatsby and other platforms.
Stars: ✭ 41 (+51.85%)
Mutual labels:  react-hooks
use-async-resource
A custom React hook for simple data fetching with React Suspense
Stars: ✭ 92 (+240.74%)
Mutual labels:  react-hooks

Processor

CircleCI npm bundle size (scoped) npm (scoped) NPM

A simple and lightweight JavaScript data processing tool.

English | 简体中文

Generally, data is processed by the server, and the frontend application interacts with the server through the API. However, when dealing with simple data, we can leave this work to the browser which can effectively reduce the number of network requests and improve the user experience. Moreover, it is very simple to develop.

Processor is such a tool which can help you processing data on the frontend.

Installnation

npm

$ npm install @processor/core

yarn

$ yarn add @processor/core

CDN

jsDelivr

Usage

First of all, you should create a instance of processor. You can pass by source data when created it.

import { createProcessor } from "@processor/core";

const data = [
  { name: "Patricia Clark", age: 16, sex: "male" },
  { name: "Michael Hall", age: 18, sex: "female" },
  { name: "Thomas Perez", age: 14, sex: "female" },
  { name: "Mark Taylor", age: 11, sex: "male" },
];
const processor = createProcessor(data);

Or provide data later by method load.

const processor = createProcessor();
processor.load(data);

Listen update event

Call onUpdate to register callback function on processor instance to get the result after processing.

processor.onUpdate((result) => {
  console.log(result);
});

// result
{
  current: [
     { name: "Michael Hall", age: 18, sex: "female" }
     ...
  ], // current entries
  page: 1, // current page number
  pageCount: 4, // page count
  total: 4 // total number of entries
}

Pagination

page(size?: number, current?: number) => Processor

Call page to set the maximum number of entries per page and current page number. If size equal or less then 0, it will return all of entries.

processor.page(1, 2); // maximum 1 entry per page and switch to second page.
processor.page(); // all of entries

Sort

Same with lodash/orderby. You can also provide a custom sort function like Array.sort

processor.sort("name"); // single field asc
processor.sort("name", "desc"); // single field desc
processor.sort(["name", "age"]); // multiple fields asc
processor.sort(["name", "age"], ["acs", "desc"]); // multiple fields with different orders
processor.sort((a, b) => a > b); // custom sort function

Search

search(str: string, fields?: string[]) => Processor

The default search strategy is "If any field of entry matched, it is considered valid". You can provide a searching range.

processor.search("pat"); // search all of fields
processor.search("pat", ["name"]); // only search field "name"

Or you can also provide a custom search strategy.

processor.search((entires) => [...]);

Filter

The filter is a quite flexible method, just see the example code below.

// name === "Patricia Clark"
processor.filter({ name: "Patricia Clark" });
// name === "Patricia Clark" || name === "Michael Hall"
processor.filter({ name: ["Patricia Clark", "Michael Hall"] });
// age > 16
processor.filter({ age: (val) => val > 16 });
// sex === "female" && age > 16
processor.filter({ sex: "female", age: (val) => val > 16 });

The filter conditions can be combined at you will.

exec

Calculate immediately and return the result.

const result = processor.page(2).filter({ sex: "female" }).search("Tho").exec();

How to use with Vue

From v2.0, it works for Vue 2 & 3 within a single package by the power of Vue Demi!

For Vue 2.x, you should install the Composition API Plugin before.

npm

$ npm install @vue/composition-api

yarn

$ yarn add @vue/composition-api
import Vue from "vue";
import VueCompositionApi from "@vue/composition-api";

Vue.use(VueCompositionApi);

Usage

npm

$ npm install @processor/vue

yarn

$ yarn add @processor/vue
import { useProcessor } from "@processor/vue";
import { reactive } from "vue";

const config = reactive({
  source: [], // source data
  searchOption: "", // first argument of process.search()
  searchFields: [], // second argument of process.search()
  filterOption: {}, // argument of process.filter()
  sortOption: "", // first argument of process.sort()
  sortOrder: "", // second argument of process.sort()
  pageSize: "", // first argument of process.page()
});
const {
  data,
  total,
  pageCount,
  currentPage, // this ref can be changed
} = useProcessor();

Change config to process data.

<input v-model="config.searchOption">
<button @click="currentPage++">next</button>

How to use with React

Need react version >=16.8.0.

npm

$ npm install @processor/react

yarn

$ yarn add @processor/react
import { useProcessor } from "@processor/react";
const { processor, result } = useProcessor(data);
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].