@am92/securities-utility
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

@am92/securities-utility

npm version  ECMAScript Module  License: MIT  Vulnerabilities: Snyk  Downloads Bundle Size


Table of Content


Installation

$ npm install --save @am92/securities-utility

Initialization

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

  1. 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)
}
  1. Include the File in index.html

    Add the following script tag to your index.html to include the file:
<script type='module' src='./initializeSecMaster.ts'></script>


Initialized Security Master With Search Module

initializeSecMaster.ts

  1. 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_URL environment variable is correctly configured for your deployment environment.

This streamlined approach keeps your application setup simple while leveraging the package's internal optimizations.


Contributors

Ankit Gandhi
Ankit Gandhi
Mehul Agarwal
Mehul Agarwal
Suyash Jadhav
Suyash Jadhav

Resources


License



Readme

Keywords

Package Sidebar

Install

npm i @am92/securities-utility

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

109 kB

Total Files

57

Last publish

Collaborators

  • heliumtank92
  • agarwalmehul
  • ankitgandhi452