npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hfs-utilities

v2.4.0

Published

Health Fund Solution's internal utilities library for Typescript projects

Downloads

144

Readme

semantic-release: angular License: ISC Dependabot GitHub Actions Gulp Azure Visual Studio Code TypeScript ESLint Mocha GitHub TS-Standard - Typescript Standard Style Guide

hfs-utilities

Utilities library for Health Fund Solutions Typescript projects.

BlockBlobService examples:

// Import the library
import { BlockBlobService } from 'hfs-utilities'

// Create a new instance of the service. Optionally provide connection string and container name.
const blockBlobService: BlockBlobService = new BlockBlobService('INSERT PRIMARY CONNECTION STRING HERE')
// Reads the blob contents, will attempt to parse to JSON if possible
const blobContents: any = await blockBlobService.read('blobFile.txt', 'containerName')

// Write the blob contents
await blockBlobService.write('blobFile.txt', 'containerName', 'Hello World!')
// Delete the blob
await blockBlobService.delete('blobFile.txt', 'containerName')
// Delete the container
await blockBlobService.deleteContainer('containerName')
// Create the container
await blockBlobService.createContainer('containerName')

// Lists the blobs in the container
const blobs: string[] = await blockBlobService.listBlobs('containerName')
// Checks if the container exists
const containerExists: boolean = await blockBlobService.containerExists('containerName')
// Checks if the blob exists
const blobExists = await blockBlobService.blobExists('blobFile.txt', 'containerName')
// Lists the containers in a storage account
const containers: string[] = await blockBlobService.listContainers()

NOTE: If working within one container, it is more convenient to pass the container name into the constructor right away, and then you do not need to pass it to any of the other methods.

AzureDataTables examples:

// Import the library
import { AzureDataTables } from 'hfs-utilities'

const azureDataTables: AzureDataTables = new AzureDataTables('INSERT PRIMARY CONNECTION STRING HERE', 'tableName')

// toTableRow converts any object to a table row by stringifying it's values
const tableRow: TableRow = azureDataTables.toTableRow({
  primaryKey: 'primaryKey',
  rowKey: 'rowKey',
  data: {
    column1: 'value1',
    column2: ['value2'],
    }
  id: 1
  })

  // isTableRecord checks if the object is a valid table record, i.e. has a partitionKey & rowKey that are strings with
  // length > 0 and all properties are valid data types
   // will return true
  const isTableRecord: boolean = azureDataTables.isTableRecord(tableRow)
   // will return false
  const isNotTableRecord: boolean = azureDataTables.isTableRecord({})

  // returns an array of one or more responses from the azure data tables service
  const response: TableTransactionResponse[] = await azureDataTables.upsert(tableRow)
  console.log(response) // would expect
    // [{
    // status: 202,
    // subResponses: [ [Object], [Object] ],
    // getResponseForEntity: [Function: getResponseForEntity]
    // }]

  // delete a table row
  const response: TableTransactionResponse[] = await azureDataTables.delete(tableRow)

  // create a table row
  const response: TableTransactionResponse[] = await azureDataTables.create(tableRow)
  const results = await azureDataTables.query('SELECT * FROM tableName')
  console.log(results) // would expect
  // [{
  //   etag: `W/"datetime'2022-06-17T13%3A18%3A17.1793353Z'"`,
  //   partitionKey: 'P2',
  //   rowKey: 'R178',
  //   timestamp: '2022-06-17T13:18:17.1793353Z'
  // },
  // {
  //   etag: `W/"datetime'2022-06-17T13%3A18%3A17.2303059Z'"`,
  //   partitionKey: 'P2',
  //   rowKey: 'R179',
  //   timestamp: '2022-06-17T13:18:17.2303059Z'
  // }]

Utilities examples:

// Import the library
import {
  isEmpty,
  isNullOrUndefined,
  isNotNullAndNotUndefined,
  asArray,
  is,
  isEmptyString,
  isNotEmptyString,
  isString,
} from 'hfs-utilities'

// isEmpty checks if the value is empty
const isEmpty: boolean = isEmpty('') // true
const isNotEmpty: boolean = isNotEmpty('test') // false

// isNullOrUndefined checks if the value is null or undefined
const isNullOrUndefined: boolean = isNullOrUndefined(null) // true
const isNotNullOrUndefined: boolean = isNotNullOrUndefined('test') // false

// isNotNullAndNotUndefined checks if the value is not null or undefined
const isNotNullAndNotUndefined: boolean = isNotNullAndNotUndefined('test') // true
const isNullAndNotUndefined: boolean = isNullAndNotUndefined(null) // false

// asArray converts a value to an array if it is not already an array
const asArray: string[] = asArray('test') // returns ['test']
const asArray: string[] = asArray(['test']) // returns ['test']

// is checks if the value is of the specified type
const isString: boolean = is('string', 'string') // true
const isNotString: boolean = is('string', 2) // false

// isEmptyString checks if the value when trimmed is an empty string
const isEmptyString: boolean = isEmptyString('      ') // true
const isNotEmptyString: boolean = isEmptyString('test') // false

// isNotEmptyString checks if the value when trimmed is not an empty string
const isEmptyString: boolean = isNotEmptyString('      ') // false
const isNotEmptyString: boolean = isNotEmptyString('test') // true

// isString checks if the value is a string
const isString: boolean = isString('string') // true
const isNotString: boolean = isString(2) // false

interfaces

import { AzureFunctionSchema } from 'hfs-utilities'