Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
incremental-search-keywords
Advanced tools
JavaScript library to extract incremental keywords from a string or object
This is a JavaScript library that provides functionality to extract keywords from a string, an object, or an array of strings. The main function of the library is extract
.
To install the library, use the following command:
npm install incremental-search-keywords
## Browser Usage
You can also use the `extract` function in a browser environment. First, include the library in your HTML file:
```html
<script src="path/to/incremental-search-keywords.js" ></script>
Then, you can use the extract
function to extract keywords from a string, an object, or an array of strings. Here's an example:
const input = "This is a sample string for testing the keyword extractor library.";
const options = {
minWordLength: 3,
skipDigits: true,
skipSpecialCharacters: true,
skipStopWords: true,
stopWords: ['the', 'a', 'is', 'for'],
asItIs: ['keyword', 'extractor'] // Array of words to be included as they are
};
const keywords = extract(input, options);
console.log(keywords);
In this example, the extract
function will extract keywords from the input
string based on the options
object. The options
object specifies that the minimum length of a keyword should be 3, digits should be skipped, special characters should be skipped, stop words should be skipped, and the stop words are 'the', 'a', 'is', and 'for'.
First, import the extract
function from the library:
const { extract } = require('keyword-extractor-library');
Then, you can use the extract
function to extract keywords from a string, an object, or an array of strings. Here's an example:
const input = { "title": "This is a sample string for testing the keyword extractor library." };
const options = {
minWordLength: 3,
skipDigits: true,
skipSpecialCharacters: true,
skipStopWords: true,
stopWords: ['the', 'a', 'is', 'for']
};
const keywords = extract(input, options);
console.log(keywords);
In this example, the extract
function will extract keywords from the input
string based on the options
object. The options
object specifies that the minimum length of a keyword should be 3, digits should be skipped, special characters should be skipped, stop words should be skipped, and the stop words are 'the', 'a', 'is', and 'for'.
extract
The extract
function has some default options that you can override if necessary. Here's a description of each option:
minWordLength
: This option specifies the minimum length of a word to be considered for extraction. The default minimum length is 3.
skipDigits
: This option specifies whether to skip words that are purely digits. The default is true, meaning words that are purely digits are skipped.
skipSpecialCharacters
: This option specifies whether to skip words that contain special characters. The default is true, meaning words with special characters are skipped.
skipStopWords
: This option specifies whether to skip words that are considered common, or "stop words". The default is true, meaning stop words are skipped.
stopWords
: This option allows you to provide your own list of stop words. The default is a predefined list of common stop words.
keys
: This option allows you to provide a list of keys to extract from the input if the input is an object. The default is null, meaning all keys are considered.
omit
: This option allows you to provide a list of keys to omit from the input if the input is an object. The default is an empty array, meaning no keys are omitted by default. In case both keys and omit are present, keys takes priority
asItIs
: This option allows you to specify an array of words that should be included in the output without modification, regardless of other filtering options such as skipDigits
, skipSpecialCharacters
, or skipStopWords
. This is useful for ensuring specific keywords or phrases are always included in the extracted results. The default is an empty array, meaning no words are included as-is by default.
Here's an example of how to override the default options:
const options = {
minWordLength: 2,
skipDigits: false,
skipSpecialCharacters: false,
skipStopWords: false,
stopWords: ['my', 'custom', 'stopwords'],
keys: ['key1', 'key2']
};
const keywords = extract('This is a test string', options);
FAQs
JavaScript library to extract incremental keywords from a string or object
We found that incremental-search-keywords demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.