Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse the nodejs check #265

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ tmp
log
issue
node
yarn.lock
4 changes: 2 additions & 2 deletions dist/flexsearch.bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import Index from "./src";
import Document from "./src/document";
import WorkerIndex from "./src/worker";

declare module "flexsearch" {
export interface Index<T> {
readonly id: string;
Expand Down Expand Up @@ -123,6 +127,9 @@ declare module "flexsearch" {
type Cursor = string;

export default class FlexSearch {
static Worker = WorkerIndex
static Index = Index
static Document = Document
static create<T>(options?: CreateOptions): Index<T>;
static registerMatcher(matcher: Matcher): typeof FlexSearch;
static registerEncoder(name: string, encoder: EncoderFn): typeof FlexSearch;
Expand Down
4 changes: 2 additions & 2 deletions src/worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function WorkerIndex(options){

factory = factory.toString();
}

const is_node_js = self["exports"];
const is_browser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
const is_node_js = !is_browser;
const _self = this;

this.worker = create(factory, is_node_js, options["worker"]);
Expand Down