1.0.75 • Published 5 years ago

starke v1.0.75

Weekly downloads
2
License
Apache License 2....
Repository
github
Last release
5 years ago

starke

starke means powerful

wonderful utils for javascript developer

模块简介

名称备注
CircularFormat环形对象格式化
Schedule定时任务的载体
ScheduleQueue按顺序执行定时任务的队列
StarkeLogger在控制台打印多彩的日志
DeterminationUtil 算法

Example of Determination

1. isEmpty Function

// isEmpty support strict or loose non-empty judgment of objects
// It can effectively avoid the null pointer problem in front-end development.
const obj = {
    name: '',
    auhtor: '',
    hobby: []
}
// false
const empty = isEmpty(obj)
// ture
const empty = isEmpty(obj, true)

2. clearObject Function

// Sometimes we want to keep the keys of the object while emptying the cache
let cache = {
    name: 'starke',
    auhtor: '4everlynn',
    hobby: ['coding', 'music']
}
// after call this obj will be empty
// like {name: '', author: '', hobby: []} 
// which could be judged as true by isEmpty
clearObject(obj)

3. equals Function

// Sometimes we want to determine whether two objects are equal in attribute values.
// this function will be usefull
let user = {
    name: '4everlynn',
    hobby: ['coding', 'music']
}
let cache = {
    name: '4everlynn',
    hobby: ['coding', 'music']
}
// false
const isEqual = user === cache
// true
const starkeEq = equals(user, cache)
// It can even handle the equality of ring objects.
// And starke create this function by hash, which is very stable

4. hash Function

// Get the hash code of the string
const string = 'Hello Starke'
const code = hash(string)

5. filter Function

// Filter array by condition
const users = [{
    user: '4everlynn',
    age: 20
}, {
    user: 'Starke',
    age: 1
}, {
    user: 'Lynn',
    age: 18
}]
/** result 
 [{
    user: '4everlynn',
    age: 20
}, {
    user: 'Lynn',
    age: 18
}]
 */
const target = filter(users, item => {
    return item.age < 20
})

6. group Function

// group array by condition
const users = [{
    user: '4everlynn',
    age: 20,
    role: 'admin'
}, {
    user: 'Starke',
    age: 1,
    role: 'admin'
}, {
    user: 'Lynn',
    age: 18,
    role: 'user'
}]
// result:
// [ [ { user: '4everlynn', age: 20, role: 'admin' },
//         { user: 'Starke', age: 1, role: 'admin' } ],
//       [ { user: 'Lynn', age: 18, role: 'user' } ] ]
const target = group(users, item => {
    // group by 'role'
    return item.role
})

7. hashColor Function

const category = 'Operate'
// Generate a stable RGB color based on the string
// rgb(232.2421875, 160, 244)
const color = hashColor(category)
// No matter how many times it runs, the result is the same.
1.0.75

5 years ago

1.0.74

5 years ago

1.0.73

5 years ago

1.0.72

5 years ago

1.0.71

5 years ago

1.0.69

5 years ago

1.0.70

5 years ago

1.0.68

5 years ago

1.0.66

5 years ago

1.0.65

5 years ago

1.0.67

5 years ago

1.0.64

5 years ago

1.0.62

6 years ago

1.0.61

6 years ago

1.0.63

6 years ago

1.0.60

6 years ago

1.0.59

6 years ago

1.0.58

6 years ago

1.0.57

6 years ago

1.0.56

6 years ago

1.0.55

6 years ago

1.0.54

6 years ago

1.0.53

6 years ago

1.0.52

6 years ago

1.0.51

6 years ago

1.0.49

6 years ago

1.0.48

6 years ago

1.0.47

6 years ago

1.0.46

6 years ago

1.0.45

6 years ago

1.0.43

6 years ago

1.0.42

6 years ago

1.0.41

6 years ago

1.0.40

6 years ago

1.0.39

6 years ago

1.0.38

6 years ago

1.0.37

6 years ago

1.0.36

6 years ago

1.0.35

6 years ago

1.0.34

6 years ago

1.0.33

6 years ago

1.0.32

6 years ago

1.0.31

6 years ago

1.0.30

6 years ago

1.0.29

6 years ago

1.0.28

6 years ago

1.0.27

6 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago

1.0.20

6 years ago

1.0.19

6 years ago

1.0.18

6 years ago

1.0.17

6 years ago

1.0.16

6 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago