MCPcopy
hub / github.com/fabiospampinato/cash / data

Function data

src/data/data.ts:19–55  ·  view source on GitHub ↗
( this: Cash, name?: string | Record<string, any>, value?: any )

Source from the content-addressed store, hash-verified

17function data ( this: Cash, name: string, value: any ): Cash;
18function data ( this: Cash, name: Record<string, any> ): Cash;
19function data ( this: Cash, name?: string | Record<string, any>, value?: any ) {
20
21 if ( !name ) {
22
23 if ( !this[0] ) return;
24
25 const datas: { [data: string]: any } = {};
26
27 for ( const key in this[0].dataset ) {
28
29 datas[key] = getData ( this[0], key );
30
31 }
32
33 return datas;
34
35 }
36
37 if ( isString ( name ) ) {
38
39 if ( arguments.length < 2 ) return this[0] && getData ( this[0], name );
40
41 if ( isUndefined ( value ) ) return this;
42
43 return this.each ( ( i, ele ) => { setData ( ele, name, value ) } );
44
45 }
46
47 for ( const key in name ) {
48
49 this.data ( key, name[key] );
50
51 }
52
53 return this;
54
55}
56
57fn.data = data;

Callers

nothing calls this directly

Calls 6

getDataFunction · 0.85
isStringFunction · 0.85
isUndefinedFunction · 0.85
setDataFunction · 0.85
dataMethod · 0.80
eachMethod · 0.65

Tested by

no test coverage detected