Skip to content

Commit

Permalink
New release process
Browse files Browse the repository at this point in the history
  • Loading branch information
krisk committed Mar 9, 2020
1 parent 2f57fe1 commit e40349d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 37 deletions.
34 changes: 17 additions & 17 deletions dist/fuse.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,40 @@ export = Fuse;
export as namespace Fuse;

interface SearchOpts {
limit?: number
limit?: number;
}

declare class Fuse<T, O extends Fuse.FuseOptions<T>> {
constructor(list: ReadonlyArray<T>, options?: O)
constructor(list: ReadonlyArray<T>, options?: O);
search<
/** Type of item of return */
R = O extends { id: string } ? string : T,
/** include score (boolean) */
S = O['includeScore'],
S = O["includeScore"],
/** include matches (boolean) */
M = O['includeMatches'],
>(pattern: string, opts?: SearchOpts):
S extends true ? (
M extends true ?
(Fuse.FuseResultWithMatches<R> & Fuse.FuseResultWithScore<R>)[] :
Fuse.FuseResultWithScore<R>[]
) : (
M extends true ?
Fuse.FuseResultWithMatches<R>[] :
R[]
)
M = O["includeMatches"]
>(
pattern: string,
opts?: SearchOpts
): S extends true
? M extends true
? (Fuse.FuseResultWithMatches<R> & Fuse.FuseResultWithScore<R>)[]
: Fuse.FuseResultWithScore<R>[]
: M extends true
? Fuse.FuseResultWithMatches<R>[]
: R[];

setCollection(list: ReadonlyArray<T>): ReadonlyArray<T>;
list: ReadonlyArray<T>
list: ReadonlyArray<T>;
}

declare namespace Fuse {
export interface FuseResultWithScore<T> {
item: T,
item: T;
score: number;
}
export interface FuseResultWithMatches<T> {
item: T,
item: T;
matches: any;
}
export interface FuseOptions<T> {
Expand Down
10 changes: 10 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ done < package.json;

echo $version;

on_master_branch () {
[[ $(git symbolic-ref --short -q HEAD) == "master" ]] && return 0
return 1
}

if ! on_master_branch; then
echo -e "\033[0;31mRefusing to release from non master branch.\033[0m"
exit 1
fi

read -e -p "Are you sure you want to release? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
Expand Down
2 changes: 1 addition & 1 deletion src/bitap/bitap_matched_indices.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = (matchmask = [], minMatchCharLength = 1) => {

// (i-1 - start) + 1 => i - start
if (matchmask[i - 1] && (i - start) >= minMatchCharLength) {
matchedIndices.push([start, i - 1])
matchedIndices.push([start, i - 1]);
}

return matchedIndices
Expand Down
4 changes: 2 additions & 2 deletions src/bitap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const bitapSearch = require('./bitap_search')
const patternAlphabet = require('./bitap_pattern_alphabet')

class Bitap {
constructor (pattern, {
constructor(pattern, {
// Approximately where in the text is the pattern expected to be found?
location = 0,
// Determines how close the match must be to the fuzzy location (specified above).
Expand Down Expand Up @@ -48,7 +48,7 @@ class Bitap {
}
}

search (text) {
search(text) {
const { isCaseSensitive, includeMatches } = this.options

if (!isCaseSensitive) {
Expand Down
34 changes: 17 additions & 17 deletions src/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ export = Fuse;
export as namespace Fuse;

interface SearchOpts {
limit?: number
limit?: number;
}

declare class Fuse<T, O extends Fuse.FuseOptions<T>> {
constructor(list: ReadonlyArray<T>, options?: O)
constructor(list: ReadonlyArray<T>, options?: O);
search<
/** Type of item of return */
R = O extends { id: string } ? string : T,
/** include score (boolean) */
S = O['includeScore'],
S = O["includeScore"],
/** include matches (boolean) */
M = O['includeMatches'],
>(pattern: string, opts?: SearchOpts):
S extends true ? (
M extends true ?
(Fuse.FuseResultWithMatches<R> & Fuse.FuseResultWithScore<R>)[] :
Fuse.FuseResultWithScore<R>[]
) : (
M extends true ?
Fuse.FuseResultWithMatches<R>[] :
R[]
)
M = O["includeMatches"]
>(
pattern: string,
opts?: SearchOpts
): S extends true
? M extends true
? (Fuse.FuseResultWithMatches<R> & Fuse.FuseResultWithScore<R>)[]
: Fuse.FuseResultWithScore<R>[]
: M extends true
? Fuse.FuseResultWithMatches<R>[]
: R[];

setCollection(list: ReadonlyArray<T>): ReadonlyArray<T>;
list: ReadonlyArray<T>
list: ReadonlyArray<T>;
}

declare namespace Fuse {
export interface FuseResultWithScore<T> {
item: T,
item: T;
score: number;
}
export interface FuseResultWithMatches<T> {
item: T,
item: T;
matches: any;
}
export interface FuseOptions<T> {
Expand Down

0 comments on commit e40349d

Please sign in to comment.