1.46.80 • Published 9 months ago

sr_core_ts v1.46.80

Weekly downloads
7
License
UNLICENSED
Repository
github
Last release
9 months ago

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"
1.46.80

9 months ago

1.46.79

12 months ago

1.46.78

12 months ago

1.46.77

12 months ago

1.46.71

1 year ago

1.46.70

1 year ago

1.46.73

1 year ago

1.46.72

1 year ago

1.46.75

1 year ago

1.46.74

1 year ago

1.46.76

1 year ago

1.46.68

1 year ago

1.46.67

1 year ago

1.46.69

1 year ago

1.46.60

1 year ago

1.46.62

1 year ago

1.46.61

1 year ago

1.46.64

1 year ago

1.46.63

1 year ago

1.46.66

1 year ago

1.46.65

1 year ago

1.46.57

1 year ago

1.46.59

1 year ago

1.46.58

1 year ago

1.46.56

3 years ago

1.46.55

3 years ago

1.46.54

3 years ago

1.46.53

3 years ago

1.46.52

3 years ago

1.46.51

3 years ago

1.46.50

3 years ago

1.46.49

3 years ago

1.46.48

3 years ago

1.46.46

3 years ago

1.46.47

3 years ago

1.46.45

3 years ago

1.46.44

3 years ago

1.46.43

3 years ago

1.46.42

4 years ago

1.46.41

4 years ago

1.46.40

4 years ago

1.46.39

4 years ago

1.46.38

4 years ago

1.46.37

4 years ago

1.46.35

4 years ago

1.46.36

4 years ago

1.46.34

4 years ago

1.46.33

4 years ago

1.46.32

4 years ago

1.46.31

4 years ago

1.46.30

4 years ago

1.46.29

4 years ago

1.46.28

4 years ago

1.46.27

4 years ago

1.46.26

4 years ago

1.46.25

4 years ago

1.46.24

4 years ago

1.46.23

4 years ago

1.46.22

4 years ago

1.46.21

4 years ago

1.46.20

4 years ago

1.46.17

4 years ago

1.46.19

4 years ago

1.46.18

4 years ago

1.46.16

4 years ago

1.46.15

4 years ago

1.46.14

4 years ago

1.46.13

4 years ago

1.46.12

4 years ago

1.46.11

4 years ago

1.46.10

4 years ago

1.46.8

4 years ago

1.46.9

4 years ago

1.46.7

4 years ago

1.46.6

4 years ago

1.46.5

4 years ago

1.46.4

4 years ago

1.46.3

4 years ago

1.46.2

4 years ago

1.46.1

4 years ago

1.46.0

4 years ago

1.45.0

4 years ago

1.44.0

4 years ago

1.43.0

4 years ago

1.38.0

4 years ago

1.39.0

4 years ago

1.40.0

4 years ago

1.42.0

4 years ago

1.41.0

4 years ago

1.36.0

4 years ago

1.37.0

4 years ago

1.35.0

4 years ago

1.34.0

4 years ago

1.33.0

4 years ago

1.32.0

4 years ago

1.31.0

4 years ago

1.30.2

4 years ago

1.30.1

4 years ago

1.30.0

4 years ago

1.29.0

4 years ago

1.27.0

4 years ago

1.28.0

4 years ago

1.26.0

4 years ago

1.25.0

4 years ago

1.23.2

4 years ago

1.23.1

4 years ago

1.23.0

4 years ago

1.21.0

4 years ago

1.22.0

4 years ago

1.19.0

4 years ago

1.20.0

4 years ago

1.18.0

4 years ago

1.17.0

4 years ago

1.16.0

4 years ago

1.15.0

4 years ago

1.14.0

4 years ago

1.13.0

4 years ago

1.9.0

4 years ago

1.11.0

4 years ago

1.10.0

4 years ago

1.8.0

4 years ago

1.7.0

4 years ago

1.6.0

4 years ago

1.5.0

4 years ago

1.4.0

4 years ago