0.0.11 • Published 6 years ago

kits-js v0.0.11

Weekly downloads
78
License
MIT
Repository
github
Last release
6 years ago

kits-js

a easy use js library for some operates with js  

1. http

1.1 http.fetch(option)

1.2 http.ajax(option)

1.3 http.jsonp(option)

option parameters:

paramtypedescription
urlStringThe URL of the resource/api
timeoutNumberThe URL of the resource/api
methodStringGET or POST method default GET
successFunctionthe request success callback
failFunctionthe request fail callback

example:

    http.fetch({
        url: 'http://jsonplaceholder.typicode.com/users/1',
        method: 'GET',
        success: (rs) => {
        },
        fail: (rs) => {
        }
    });

1.4 http.download(url,fileName)

paramtypedescription
urlStringThe URL of the resource/api
fileNameStringthe name you want to name the file

2. obj

for Object operations

2.1. obj.deepClone(source)

source: 
    the Object you want to deep clone
return:
    an object the same as source
    let clone = obj.deepClone({name:'Daniel',age:44})

2.2. obj.diff(src1,src2)

src1/src2:     
    the object you want to get the diff of two objects   
return:   
    return the diff of src2 relative to src1   
    var o1 = {
        a: {
            aa: {
                aaa: 1
            },
            bb: {
                bbb: 2
            }
        },
        b: 'hello',
        e: 'o2 dont have',
        g: 'o2 different',
    }
    var o2 = {
        a: {
            aa: {
                aaa: 'first'
            },
            bb: {
                bbb: 2
            }
        },
        c: 'daniel',
        f: 'o1 dont have',
        g: 'different',
    }
    let diff = obj.diff(o1,o2);

2.3. obj.merge(src1,src2)

src1/src2:  
    the same as obj.diff  
return:  
    return the merged object of src1 && src2  
    the src2 will only overwrite the string/number property values of src1

example:

    let merged = obj.merge(o1,o2)
0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago