Skip to content

Commit bfcd72a

Browse files
committed
Rename package and reorganize
1 parent 5e25cb2 commit bfcd72a

File tree

19 files changed

+411
-386
lines changed

19 files changed

+411
-386
lines changed

lib/node_modules/@stdlib/_tools/search/create/lib/create_index.js

Lines changed: 0 additions & 170 deletions
This file was deleted.

lib/node_modules/@stdlib/_tools/search/create/lib/get_existing.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

lib/node_modules/@stdlib/_tools/search/create/README.md renamed to lib/node_modules/@stdlib/_tools/search/pkg-index/README.md

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ limitations under the License.
2020

2121
# Search Index
2222

23-
> Create a serialized [lunr.js][lunr-js] search index.
23+
> Generate a serialized [lunr.js][lunr-js] search index.
2424
2525
<section class="usage">
2626

2727
## Usage
2828

2929
```javascript
30-
var create = require( '@stdlib/_tools/search/create' );
30+
var pkgIndex = require( '@stdlib/_tools/search/pkg-index' );
3131
```
3232

33-
#### create( \[options,] clbk )
33+
#### pkgIndex( \[options,] clbk )
3434

35-
Asynchronously creates a serialized [lunr.js][lunr-js] search index.
35+
Asynchronously generates a serialized [lunr.js][lunr-js] search index.
3636

3737
```javascript
38-
create( onCreate );
38+
pkgIndex( clbk );
3939

40-
function onCreate( error, idx ) {
40+
function clbk( error, idx ) {
4141
if ( error ) {
4242
throw error;
4343
}
@@ -60,9 +60,9 @@ var opts = {
6060
'dir': '/foo/bar/baz'
6161
};
6262

63-
create( opts, onCreate );
63+
pkgIndex( opts, clbk );
6464

65-
function onCreate( error, idx ) {
65+
function clbk( error, idx ) {
6666
if ( error ) {
6767
throw error;
6868
}
@@ -79,9 +79,9 @@ var opts = {
7979
'pattern': '**/foo/**/package.json'
8080
};
8181

82-
create( opts, onCreate );
82+
pkgIndex( opts, clbk );
8383

84-
function onCreate( error, idx ) {
84+
function clbk( error, idx ) {
8585
if ( error ) {
8686
throw error;
8787
}
@@ -102,9 +102,9 @@ var opts = {
102102
]
103103
};
104104

105-
create( opts, onCreate );
105+
pkgIndex( opts, clbk );
106106

107-
function onCreate( error, idx ) {
107+
function clbk( error, idx ) {
108108
if ( error ) {
109109
throw error;
110110
}
@@ -127,22 +127,32 @@ function onCreate( error, idx ) {
127127
<!-- eslint-disable stdlib/no-internal-require -->
128128

129129
```javascript
130+
var join = require( 'path' ).join;
130131
var lunr = require( 'lunr' );
131-
var create = require( '@stdlib/_tools/search/create' );
132+
var rootDir = require( '@stdlib/_tools/utils/root-dir' );
133+
var pkgIndex = require( '@stdlib/_tools/search/pkg-index' );
132134

133-
create({
134-
'dir': '/path/to/stdlib/lib/node_modules/@stdlib'
135-
}, onCreate );
135+
// Define a directory containing READMEs from which to create a search index:
136+
var dir = join( rootDir(), 'lib', 'node_modules', '@stdlib', 'math', 'base', 'special' );
136137

137-
function onCreate( error, idx ) {
138+
// Create a search index:
139+
var opts = {
140+
'dir': dir
141+
};
142+
pkgIndex( opts, onIndex );
143+
144+
function onIndex( error, idx ) {
138145
var store;
146+
var res;
139147
if ( error ) {
140148
throw error;
141149
}
150+
// Load the serialized index into Lunr:
142151
store = lunr.Index.load( idx );
143152

144153
// Perform a search:
145-
console.log( store.search( 'encrypt' ) );
154+
res = store.search( 'sine' );
155+
console.log( JSON.stringify( res, null, ' ' ) );
146156
}
147157
```
148158

@@ -161,7 +171,7 @@ function onCreate( error, idx ) {
161171
### Usage
162172

163173
```bash
164-
Usage: create-search [options] [<dir>]
174+
Usage: stdlib-pkg-index [options] [<dir>]
165175

166176
Options:
167177

@@ -184,7 +194,7 @@ Options:
184194
- To provide multiple exclusion glob patterns, set multiple `--ignore` option arguments.
185195

186196
```bash
187-
$ create-search --ignore=node_modules/** --ignore=build/** --ignore=reports/**
197+
$ stdlib-pkg-index --ignore=node_modules/** --ignore=build/** --ignore=reports/**
188198
```
189199

190200
</section>
@@ -196,7 +206,7 @@ Options:
196206
### Examples
197207

198208
```bash
199-
$ create-search . > search_index.json
209+
$ stdlib-pkg-index . > search_index.json
200210
```
201211

202212
</section>

0 commit comments

Comments
 (0)