@am92/securities-utility
v0.1.2
Published
A utility package for securities applications
Readme
@am92/securities-utility
Table of Content
Installation
$ npm install --save @am92/securities-utilityInitialization
The initialization step downloads the security master (sec master) from the specified URL and applies optimizations to enhance the performance of subsequent functionalities. This step runs on the main thread, and the package internally manages the worker for parallel execution. You only need to include a dedicated TypeScript/JavaScript file in your index.html
Instructions
Create a New File:
Create a new TypeScript/JavaScript file (e.g.,initializeSecMaster.ts) containing the initialization code.
initializeSecMaster.ts
import { initialize } from '@am92/securities-utility'
const SEC_MASTER_URL = process.env.SEC_MASTER_URL // URL for downloading the sec master (can be environment-specific)
// Initialize the sec master
try {
initialize(SEC_MASTER_URL)
console.log('Sec master initialization successful.')
} catch (error) {
console.error('Sec master initialization failed:', error)
}Include the File in
Add the following script tag to your index.html to include the file:index.html
<script type='module' src='./initializeSecMaster.ts'></script>Initialized Security Master With Search Module
initializeSecMaster.ts
Pass
{ requireSearchModule: true }to enable the fuzzy search module during Security Master initialization.
import { initialize } from '@am92/securities-utility'
const SEC_MASTER_URL = process.env.SEC_MASTER_URL // URL for downloading the sec master (can be environment-specific)
// Initialize the sec master
try {
initialize(SEC_MASTER_URL, {
requireSearchModule: true
})
console.log('Sec master initialization successful.')
} catch (error) {
console.error('Sec master initialization failed:', error)
}Using Search Function When Required
import { searchManager } from '@am92/securities-utility'
const handleSearch = async (searchString: string) => {
const searchResult = await searchManager.search(searchString)
console.log(searchResult) // Array of matched security objects
}Notes:
- The package automatically handles the use of a web worker for parallel execution, ensuring the main thread remains unblocked.
- Ensure the
SEC_MASTER_URLenvironment variable is correctly configured for your deployment environment.
This streamlined approach keeps your application setup simple while leveraging the package's internal optimizations.
