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

sr_core_ts

v1.46.80

Published

core typescript functions

Downloads

69

Readme

common typescript functions

node specific functions in sr_core_ts have been removed and moved to new package named sr_node_core.

  • rxp - regular expression constants
  • core.ts - contains series of str_ and scan_ functions.

usage

import { dir_mkdir, str_tail, str_contains } from 'sr_core_ts';

array methods

  • arr_compareEqual( arr1, arr2 )
  • toarr = arr_copyItems( arr, start, length )
  • arr_findAndSplice( arr, predicate )
  • arr_front( arr: T[] ) : T | null
  • boolean = strArr_contains( arr, text )

object methods

  • any_toString( val )
  • obj_apply( obj1, obj2 )
  • const isEqual = obj_compareEqual( obj1, obj2 )

scan methods

scan_unquotedPattern - scan for pattern outside of quoted text.

Primary use is when scanning for control character in text of a statement. But skip when that control character is within quotes in the statement.

{index, text} = scan_unquotedPattern( text, bx, pattern )
const scanText = `repeating match hit will "<div>" check for < div> the next or`;
const { index, text } = scan_unquotedPattern( scanText, 0, '<\\s*div\\s*>');

string methods

  • {found_char, found_index } = scan_charEqAny(text,start,pattern)
  • str_assignSubstr( str, start, length, vlu ) : string
  • str_dequote( str )
  • text = str_enquote( str, quoteChar )
  • str_head( str, lx)
  • str_isQuoted( str )
  • str_matchGeneric( str: string, pattern: string ) : boolean
  • randomText = str_random( length )
  • text = str_padLeft(text, length, pad) ;
  • text = str_padRight(text, length, pad) ;
  • str_replaceAll( str, find, replace)
  • str_startsWith( str, text | string[])
  • str_substrLenient( str, bx, lx )
  • distinctArr = strArr_toDistinct( arr )
  • distinctArr = strArr_toDistinctAndSorted( arr )

string words methods

words = str_splitWords( str )

Split string into array of words. Each word stores the text of the word, the delimeter, start position, whether there is whitespace before or after the word. Each word object implements the iStringWord interface.

words = str_splitWhitespaceWords( str )

Split string into array of words, where the words are split on whitespace only.

word = strWords_wordAtPosition( words, pos )

Using the input array of iStringWord words returned by str_splitWords, return the word that is found at the specified position.

date methods

  • epoch = date_toEpoch( Date )
  • dt = date_fromISO('2020-05-15', '14:22:15')
  • text = date_toISO( dt )

regular expression methods

  • regexPattern_toFragments( pattern: string) : regexFrag_interface[]

Uint8Array methods

  • uint8Arr_toString( buf )
  • uint8Arr_toHexString( buf )
  • uint8Arr_remLx( buf )
  • uint8Arr_nextNum( buf )

publish instructions

  • increment version number in package.json
  • make sure new functions are exported from core.ts
  • update README.md to document new function or feature
  • npm run build
  • npm run test
  • git add, commit, push to repo
  • npm publish
  • npm update in projects which use this package

testing

  • npm run test
  • or press F5, run task "run tester"