Frolics is an offline, lightweight, full-text search library for Frontend applications

Overview

Frolics

What Is Frolics ?

Frolics is an offline, lightweight, full-text search library for Frontend applications.

Frolics is inspired by Elasticsearch and Lucence, the underlying implementation includes text-processing algorithms and data structure such as tokenization, stemming and inverted index.

When a docs is provided, Frolics creates an inveted index data accordingly, which is widely used in major full-text search services such as Elasticsearch and Google Search.

From now on, you can omit onerous installation process to carry out a full-text search, and even better, you may no longer need a backend to develop such feature.

Frolics is here to help!

Installation

Before installing frolics, please make sure your Node version is compatible. Node v12+ is OK but Node v16 is recommended.

However, Node v17+ had a compatibility issue when I was testing Frolics in ReactJS. But Node v16 was working well.

Once done. Run npm install frolics in terminal.

Usage

Document Preparing

Before importing, a raw data is required. It should look like this:

const docs = [
    {
        id: 1,
        body: 'this is a test full text'
    },
    {
        id: 2,
        body: 'can you can a can as a canner who can can a can',
    },
];

Keep in mind that an unique id and a text content body fields are required as id distinguishes each document and body is the content Frolics needs to analyze and classify text data for searching.

Customized Fields

In additioal to id and body as required fields, you can have multiple ones for different features. For example, if you want a preview image when searching, you can alter docs like this:

const docs = [
    {
        id: 1,
        body: 'this is a test full text',
        // imagesURL field is totally optional, you can have different name and data structure
        imagesURL: 'https://yourImage.com/img1.png',
    },
    {
        id: 2,
        body: 'can you can a can as a canner who can can a can',
    },
];

Hand-on Example

After defining docs, we are all set. Next step is to use Frolics.

Frolics supports ES6 syntax, therefore you can import like this:

import { createDTM, Stemmer } from 'frolics';
import { docs } from "../assets/document.js" // Don't forget the raw data

Now you can call createDTM like this:

const DTM = createDTM(docs);

The createDTM is the main function that takes docs and creates an inverted index dictionary.

You can trim your original input with Stemmer to obtain searched results

const DTM = createDTM(docs);
const stemmedInput = Stemmer(input);
return DTM[stemmedInput]; // The result

For the detailed example, please visit the example folder.

Cache

What createDTM function returns is an inverted index dictionary. It can be converted to human-readable JSON format with simple JavaScript built-in function JSON.stringify method.

You can choose any file reading method based on your frameworks and load the JSON file, if exists, before calling createDTM function.

You might also like...

A renderless rich-text editor for Vue.js

We’re working on tiptap 2. Become a sponsor to get access immediately! Sponsor 💖 tiptap A renderless and extendable rich-text editor for Vue.js [FAQ]

Dec 29, 2022

Obsidian plugin to add keyboard shortcuts commonly found in code editors such as Visual Studio Code or Sublime Text

Code Editor Shortcuts This Obsidian plugin adds keyboard shortcuts (hotkeys) commonly found in code editors such as Visual Studio Code or Sublime Text

Dec 30, 2022

A text replacer component for vue3.

A text replacer component for Vue 3. Requires Vue 3 as peer-dependency. Installation Install it from npm. npm install vue3-replacer pnpm add vue3-rep

Feb 19, 2022

Bionic ReadingTool - Convert Text into Better Way to Read Faster

Bionic ReadingTool - Convert Text into Better Way to Read Faster

📓 Bionic ReadingTool A revolutionary way for guiding the eyes through text using artificial fixation spots to make reading easier. As a result, the r

Dec 24, 2022

Morse code is a method used in telecommunication to encode text characters as standardized sequences of two different signal durations, called dots and dashes, or dits and dahs.

@elonehoo/point-line Install # npm npm i @elonehoo/point-line # yarn yarn add @elonehoo/point-line #pnpm pnpm i @elonehoo/point-line Usage import {dec

Aug 3, 2022

⚡A zero-config bundler for JavaScript applications.

⚡A zero-config bundler for JavaScript applications.

Poi is a bundler built on the top of webpack, trying to make developing and bundling apps with webpack as easy as possible. The Poi project is support

Jan 4, 2023

Build performant, native and cross-platform desktop applications with native Vue + powerful CSS like styling.🚀

Build performant, native and cross-platform desktop applications with native Vue + powerful CSS like styling.🚀

Vue NodeGui Build performant, native and cross-platform desktop applications with Vue. 🚀 Vue NodeGUI is powered by Vue 🌈 and Qt5 💚 which makes it C

Dec 30, 2022

Time-traveling debugger for Svelte applications

Time-traveling debugger for Svelte applications

DeLorean The first time-travelling debugger for Svelte applciations DeLorean is a debugging tool for Svelte developers. It records snapshots when a ta

Oct 8, 2022

Configure multi-pages applications and code splitting

vite-plugin-mp Configure multi-pages applications and code splitting Usage npm install vite-plugin-mp -D // vite.config.js import { defineConfig } fro

Dec 2, 2022
Comments
  • Chore: ignore the node dependencies

    Chore: ignore the node dependencies

    Why?

    Since NPM will ignore everything in node_modules, I think we should avoid uploading the node_modules to GitHub to decrease the size of the repo.

    See NPM document

    Additionally, everything in node_modules is ignored, except for bundled dependencies. npm automatically handles this for you, so don't bother adding node_modules to .npmignore.

    opened by AlanSyue 1
Owner
null
A template to use GoLang Lorca package to make desktop applications using webview and Svelte for the frontend,

Svelte Lorca Template A starter project for building modern cross-platform desktop apps in Go, HTML, and Svelte. This project is a fork of lorca-ts-re

Ben Winchester 16 Jun 19, 2022
:bento: Full-Stack solution to quickly build PWA applications with Vue.js and Firebase

Welcome to bento-starter ?? ?? bento-starter is an Open-Source Full-Stack solution that helps you to build fast and maintainable web applications usin

Franck Abgrall 1.5k Dec 24, 2022
Next generation frontend tooling. It's fast!

Vite ⚡ Next Generation Frontend Tooling ?? Instant Server Start ⚡️ Lightning Fast HMR ??️ Rich Features ?? Optimized Build ?? Universal Plugin Interfa

vite 51.2k Jan 5, 2023
Make Phaser 3 games with modern frontend tooling.

Phaser 3 + Vite.js Template Make Phaser 3 games with modern frontend tooling. Prerequisites You'll need Node.js and npm installed. It is highly recomm

ourcade 15 Dec 15, 2022
A lightweight Vue.js UI library with a simple API, inspired by Google's Material Design.

Keen UI Keen UI is a Vue.js UI library with a simple API, inspired by Google's Material Design. Keen UI is not a CSS framework. Therefore, it doesn't

Josephus Paye II 4.1k Jan 2, 2023
A svelte action for creating tippy.js tooltips with full typescript support

Tippy.js for svelte A svelte action for creating tippy.js tooltips. Getting started # Pnpm pnpm add svelte-tippy tippy.js # Yarn yarn add svelte-tipp

Brett Mandler 11 Jul 19, 2022
@auth0/auth0-spa-js wrapper in the "Vue way", with full TS support

vue-auth0 This is a wrapper around @auth0/auth0-spa-js meant to ease the usage into Vue projects. This is heavily inspired by the snippet into Auth0 o

Dreamonkey S.r.l. 5 Oct 18, 2022
demo for full-stack ci/cd

vue + nestjs (TypeScript) Features CI/CD full-stack mutiple-env (test: http://81.70.221.165:8026 / production: http://81.70.221.165) continuing~ welco

Evan Zuo 3 Oct 24, 2022
Nuxt-Module, that provides a system to set shopware cache-tags for later use in e.g. a full-page cache

nuxt-shopware-caching Nuxt-Module, that provides a system to set shopware cache-tags for later use in e.g. a full-page cache. This module is meant to

Mothership GmbH 5 Nov 8, 2022