Skip to content

Commit

Permalink
Add typedef, minor release fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahvdAa committed Jun 28, 2023
1 parent 365a2db commit 0fd9247
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
node_modules/
.idea/
node_modules/
.DS_Store
6 changes: 6 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.github/
.idea/
node_modules/
test/
.DS_Store
.editorconfig
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "A library to help you with family name prepositions in Dutch last names.",
"main": "./src/index.js",
"types": "./src/index.d.ts",
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
Expand Down
2 changes: 2 additions & 0 deletions src/dutchPrepositions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// - van de
// - van

// Based on https://nl.wikipedia.org/wiki/Tussenvoegsel

const DutchPrepositons = [
"aan den ",
"aan der ",
Expand Down
60 changes: 60 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Searches the specified last name for a preposition.
* Optionally applies search options, if provided.
*
* @param lastName The last name to extract a preposition from.
* @param options (Optional) The options to apply to the search.
* @returns A FindPrepositionResult
*/
export function findPreposition(lastName: String, options?: FindPrepositionOptions): FindPrepositionResult;

export interface FindPrepositionOptions {
/**
* The array of prepositions to use. Uses the default bundled list if not specified.
* When supplying your own list, make sure your prepositions end with a space when there
* is a space between the preposition and the last name, otherwise the trailing space
* would get included in the last name.
*
* Defaults to {@link DutchPrepositions}.
*/
prepositions?: String[];

/**
* An array of prepositions to exclude from the list. Useful if you want to exclude a specific preposition
* from the default list. Keep in mind you'll need to end most prepositions with a trailing space.
*
* Defaults to an empty array.
*/
exclude?: String[];

/**
* Ignores a preposition if no other characters remain after matching it.
*
* Defaults to true.
*/
ignoreIfNoSuffix?: Boolean;

/**
* Strips the trailing space from the preposition.
*
* Defaults to false.
*/
stripTrailingSpace?: Boolean;
}

export interface FindPrepositionResult {
/**
* The found preposition, or null if nothing was found.
*/
preposition: String | null;

/**
* The last name without the preposition, or null if the name would be an empty string.
*/
lastName: String | null;
}

/**
* A list of the most common Dutch prepositions, based on the Wikipedia article: https://nl.wikipedia.org/wiki/Tussenvoegsel
*/
export const DutchPrepositions: String[];

0 comments on commit 0fd9247

Please sign in to comment.