All Projects → yann510 → ss-search

yann510 / ss-search

Licence: other
The most basic, yet powerful text search.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to ss-search

Deep Object Diff
Deep diffs two objects, including nested structures of arrays and objects, and returns the difference. ❄️
Stars: ✭ 515 (+1156.1%)
Mutual labels:  object, array
Shallow Clone
Make a shallow clone of an object, array or primitive.
Stars: ✭ 23 (-43.9%)
Mutual labels:  object, array
Morphism
⚡ Type-safe data transformer for JavaScript, TypeScript & Node.js.
Stars: ✭ 336 (+719.51%)
Mutual labels:  object, array
Kind Of
Get the native JavaScript type of a value, fast. Used by superstruct, micromatch and many others!
Stars: ✭ 268 (+553.66%)
Mutual labels:  object, array
js-explorer
Find the method you need without digging through the docs, directly on the command line!
Stars: ✭ 287 (+600%)
Mutual labels:  object, array
Kibana Object Format
A Kibana plugin for displaying objects and arrays of objects.
Stars: ✭ 100 (+143.9%)
Mutual labels:  object, array
Moses
Utility library for functional programming in Lua
Stars: ✭ 541 (+1219.51%)
Mutual labels:  object, array
prototyped.js
Some common Typescript prototypes
Stars: ✭ 22 (-46.34%)
Mutual labels:  object, array
js-deep-sort-object
Simple module to sort objects recursively by its keys
Stars: ✭ 19 (-53.66%)
Mutual labels:  object, array
What The Filter
A visual playground to JavaScript array & object transformations.
Stars: ✭ 128 (+212.2%)
Mutual labels:  object, array
php-helpers
An extensive set of PHP helper functions and classes.
Stars: ✭ 27 (-34.15%)
Mutual labels:  object, array
utils.js
👷 🔧 zero dependencies vanilla JavaScript utils.
Stars: ✭ 14 (-65.85%)
Mutual labels:  object, array
lazy-arr
Arrays that look just like regular JavaScript arrays, but are computed lazily.
Stars: ✭ 67 (+63.41%)
Mutual labels:  array
array
Pack of advanced PHP array functions
Stars: ✭ 45 (+9.76%)
Mutual labels:  array
stringx
Drop-in replacements for base R string functions powered by stringi
Stars: ✭ 14 (-65.85%)
Mutual labels:  text
Godot-Share
Simple share text and/or image module for Godot Engine (Android & iOS)
Stars: ✭ 58 (+41.46%)
Mutual labels:  text
stock-prices
Analyzing stock prices with Fortran arrays
Stars: ✭ 24 (-41.46%)
Mutual labels:  array
pytextcodifier
📦 Turn your text files into codified images or your codified images into text files.
Stars: ✭ 14 (-65.85%)
Mutual labels:  text
text2painting
Convert text into beautiful artistic images
Stars: ✭ 55 (+34.15%)
Mutual labels:  text
AutoFormatInputWatcher
This repository contains input watcher for auto formatting digits in edit text
Stars: ✭ 15 (-63.41%)
Mutual labels:  text

npm npm bundle size Travis (.org) Coveralls github Commitizen friendly semantic-release

s(imply)s(tupid)-search

The most basic, yet powerful text search.

Stop searching, start finding.

  • Easy to use; will return you appropriate results out of the box, no need to configure anything
  • Search local array of objects as easily as never before
  • Automatic indexing
  • Will return exactly what you are looking for
  • Very small size; only depends on 5 lodash functions which are extracted using rollup, which means we have a zero dependency library

Demo

If you're not convinced yet, take a look at this interactive demo.

Install

ss-search is available on npm. It can be installed with the following command:

npm install ss-search

Usage

Basic

import { search } from "ss-search"

const data = [
     {
         number: 1,
         text: "A search function should be fast",
     },
     {
         number: 2,
         text: "A search function should provide accurate results"
     },
]
const searchKeys = ["text"] 
const searchText = "fast search"

const results = search(data, searchKeys, searchText)
// results: [{ number: 1, text: "A search function should be fast" }]

Yes. It is that simple, no need to configure anything, it works out of the box.

Data Types

Almost all data types are supported [boolean, number, string, object, array].

// This dataset will be used as a common starting point for our type examples
const data = [
    {
        boolean: true,
        number: 1,
        string: "search",
        object: { nestedProperty: "nested value" },
        array: ["value1", "value2"],
        arrayObjects: [{ arrayObjectProperty: "array object value" }],
    }
]

Boolean

const results = search(data, ["boolean"], "true")
// results: will return our original dataset

Number

const results = search(data, ["number"], "1")
// results: will return our original dataset

String

const results = search(data, ["string"], "search")
// results: will return our original dataset

Object

Providing a key which refers to an object will stringify that object using JSON.stringify

const results = search(data, ["object"], "property")
// results: will return our original dataset as it matches the property key "nestedProperty" of our object

If you want to access a nested property of an object to extract only a single value

const results = search(data, ["object.nestedProperty"], "property")
// results: will return an empty array as we extracted the value of our nested object
// if we had searched for "nested value" we would of had the original dataset

Array

Providing a key which refers to an array will stringify that array using JSON.stringify

const results = search(data, ["array"], "value2")
// results: will return our original dataset

If you have an array of objects on which you want to search all properties

const results = search(data, ["arrayObjects"], "arrayObjectProperty")
// results: will return an our original dataset as it's treated just like a regular array
// thus the arrayObjectProperty is part of the searchable text

If you have an array of objects where you want only specific properties to be searchable

const results = search(data, ["arrayObjects[arrayObjectProperty]"], "arrayObjectProperty")
// results: will return an empty array as we extracted the value of our nested array of objects
// if we had searched for "value object" we would of had the original dataset 

Benchmark

How does it compare to other search libraries? Test out for yourself with this interactive benchmark ;)

Developing

To better manage dependencies across the monorepo I'm using lerna.

The following command will install lerna (and other depedencies) and install the depedencies of all the packages of the repository.

npm i && npx lerna bootstrap --hoist

Commit format

To make things easier for all contributors, I'm using commitizen to enforce compatible commit messages with semantic-release. Also, to make sure it is enforced, I'm using husky to easily add validation hooks. When you run git commit you will be prompted with an interactive CLI to help you with the formatting of your commit message.

TLDR: making a contribution is easy peasy and you cannot go wrong ;)

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].