woonplan-packages-redishelper 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,51 +0,0 @@
1
-
2
- const isJSON = ( str:any ) => {
3
- if( typeof str == 'number' ) return false
4
- try{
5
- JSON.parse( str )
6
- }catch( error ){
7
- return false;
8
- }
9
- return true;
10
- }
11
-
12
- interface ObjectToOmitFrom{
13
- [index: string]: any;
14
- }
15
-
16
-
17
- const omit = ( objectToOmitFrom:ObjectToOmitFrom, keys:(keyof ObjectToOmitFrom)[]) =>
18
- Object.keys( objectToOmitFrom )
19
- .filter( key => keys.indexOf( key ) == -1 )
20
- .reduce( (struct:object,key) =>
21
- Object.assign( struct, {[key]:objectToOmitFrom[key]} ) ,
22
- {}
23
- )
24
-
25
-
26
-
27
- const mapJsonReplacer = ( _key:any, value:Map<any,any> | any ) => {
28
- if(value instanceof Map) {
29
- return {
30
- dataType: 'Map',
31
- value: Array.from(value.entries()), // or with spread: value: [...value]
32
- } as JsonStringifiedMap
33
- } else {
34
- return value;
35
- }
36
- }
37
-
38
- const mapJsonReviver = ( _key:any, value:JsonStringifiedMap | any ) => {
39
- if(typeof value === 'object' && value !== null) {
40
- if (value.dataType === 'Map') {
41
- return new Map(value.value);
42
- }
43
- }
44
- return value;
45
- }
46
-
47
- const stringifyMap = ( map:Map<any,any> ):string=> JSON.stringify( map, exports.mapJsonReplacer)
48
- const parseMap = ( json:string ):Map<any,any> => JSON.parse( json, exports.mapJsonReviver)
49
- const capitalizeFirstLetter = (string:string) => string.charAt(0).toUpperCase() + string.slice(1)
50
-
51
- export { isJSON, omit, mapJsonReviver, stringifyMap, parseMap, mapJsonReplacer, capitalizeFirstLetter }
package/src/types.d.ts DELETED
@@ -1,49 +0,0 @@
1
-
2
- interface JsonStringifiedMap{
3
- dataType : 'Map',
4
- value : any[]
5
- }
6
-
7
- interface RedisMessage{
8
- [index: string]: any;
9
- }
10
- interface Struct{
11
- [index: string]: any;
12
- }
13
-
14
- interface RedisConfig{
15
- REDISURL: string | number | undefined;
16
- }
17
-
18
- interface RedisStreamEntry{
19
- id : string
20
- message:RedisMessage
21
- }
22
-
23
- type StreamMessage = [
24
- string, StreamMessageParameters
25
- ]
26
-
27
- type StreamMessageParameters = string[]
28
- type StreamResponse = [
29
- string, StreamMessage[]
30
- ]
31
-
32
- interface DecypheredParameters{
33
- [index:string] : string
34
- }
35
-
36
- interface DecypheredMessage{
37
- id : string
38
- parameters : DecypheredParameters
39
- }
40
-
41
- interface DecypheredResponse{
42
- stream : string,
43
- messages : DecypheredMessage[]
44
- }
45
-
46
- interface RollbarConfig{
47
- accessToken : string
48
- environment : string
49
- }