Skip to content

Commit

Permalink
fix: semantic-release
Browse files Browse the repository at this point in the history
  • Loading branch information
yann510 committed Sep 12, 2023
1 parent f5fdfdf commit 297da64
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 36 deletions.
70 changes: 39 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/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
Expand All @@ -23,28 +25,30 @@ If you're not convinced yet, take a look at this interactive
[demo](https://ss-search.netlify.app/).

## Install

ss-search is available on [npm](https://www.npmjs.com/package/ss-search). It can be installed with the following command:

`npm install ss-search`

## Usage

### Basic

```javascript
import { search } from "ss-search"
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"
},
{
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 searchKeys = ['text']
const searchText = 'fast search'

const results = search(data, searchKeys, searchText)
// results: [{ number: 1, text: "A search function should be fast" }]
Expand All @@ -55,35 +59,39 @@ 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].

```javascript
// 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: true,
number: 1,
string: 'search',
object: { nestedProperty: 'nested value' },
array: ['value1', 'value2'],
arrayObjects: [{ arrayObjectProperty: 'array object value' }],
},
]
```

#### Boolean

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

#### Number

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

#### String

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

Expand All @@ -92,14 +100,14 @@ const results = search(data, ["string"], "search")
Providing a key which refers to an object will stringify that object using JSON.stringify

```javascript
const results = search(data, ["object"], "property")
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

```javascript
const results = search(data, ["object.nestedProperty"], "property")
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
```
Expand All @@ -109,24 +117,24 @@ const results = search(data, ["object.nestedProperty"], "property")
Providing a key which refers to an array will stringify that array using JSON.stringify

```javascript
const results = search(data, ["array"], "value2")
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

```javascript
const results = search(data, ["arrayObjects"], "arrayObjectProperty")
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

```javascript
const results = search(data, ["arrayObjects[arrayObjectProperty]"], "arrayObjectProperty")
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
// if we had searched for "value object" we would of had the original dataset
```

### Benchmark
Expand All @@ -140,10 +148,10 @@ How does it compare to other search libraries? Test out for yourself with this i
To better manage dependencies across the monorepo I'm using [NX](https://nx.dev/).

Install dependencies:
```npm i```
`npm i`

Start the web-app:
```npm run web-app:serve```
`npm run web-app:serve`

Test the library:
```npm run test:all```
`npm run test:all`
16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,30 @@
},
"nxrelease": {
"repositoryUrl": "https://github.com/yann510/ss-search",
"dryRun": true,
"tagFormat": "v${version}",
"buildTarget": "ss-search:build",
"outputPath": "dist/ss-search",
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
"assets": [
"CHANGELOG.md",
"**/package.json",
"**/package-lock.json",
"**/benchmarkResults.json"
"package.json",
"package-lock.json",
"ss-search/package.json",
"ss-search/package-lock.json",
"web-app/src/assets/benchmarkResults.json"
],
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
],
"@semantic-release/github"
]
}
}

0 comments on commit 297da64

Please sign in to comment.