Skip to content

Commit

Permalink
release v5.19.0
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Apr 27, 2024
1 parent 4b06312 commit ca77073
Show file tree
Hide file tree
Showing 11 changed files with 5,994 additions and 5,199 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.9.2
version: 9.0.6

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.9.2
version: 9.0.6

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8.9.2
version: 9.0.6

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
Expand Down
Empty file modified .gitignore
100755 → 100644
Empty file.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change logs

## 2024.04.27 v5.19.0

1. `getProperty` support defaultValue
2. fix types
3. upgrade all packages

## 2024.03.11 v5.18.1

1. fix types
Expand Down
Empty file modified README-zh_CN.md
100755 → 100644
Empty file.
41 changes: 29 additions & 12 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3502,14 +3502,17 @@ declare function fillIPv6(ip: string): string

Get array, object property values based on path string

> v5.19.0 support defaultValue

- Since: `2.2.4`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ------------------------------- | ------------------- | -------- | -------- | ------- |
| target | target array, object | `array`/`object` | - | `true` | - |
| prop | query target, can pass function | `string`/`function` | - | `true` | - |
| Parameters | Description | Type | Optional | Required | Default |
| ------------ | ------------------------------- | ------------------- | -------- | -------- | ------- |
| target | target array, object | `array`/`object` | - | `true` | - |
| prop | query target, can pass function | `string`/`function` | - | `true` | - |
| defaultValue | default value | `any` | - | `false` | - |

- Returns: `any`

Expand All @@ -3520,25 +3523,39 @@ const target = {
a: 1,
b: [
{
c: 2
c: 2,
d: NaN
}
]
}
getProperty(target, 'a') // 1
getProperty(target, 'd', 100) // 100
getProperty(target, 'b[0].c') // 2
getProperty(target, 'b[0].d', 100) // 100
getProperty(target, () => 'a') // 1
```
- Types:
```ts
declare function getProperty(
target: any,
export declare function getProperty<T extends Record<string, any>>(
target: T,
prop:
| string
| {
(): string
}
},
defaultValue?: any
): any

export declare function getProperty<T extends Array<any>>(
target: T,
prop:
| string
| {
(): string
},
defaultValue?: any
): any
```

Expand All @@ -3553,7 +3570,7 @@ Set array, object property values based on path string
| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ------------------------------------------------ | ------------------- | -------- | -------- | ------- |
| target | target array, object | `array`/`object` | - | `true` | - |
| prop | set target, can pass function, 'a' \| 'a\[1\].c' | `string`/`function` | - | `true` | - |
| prop | set target, support function, 'a' \| 'a\[1\].c' | `string`/`function` | - | `true` | - |
| value | value | `any` | - | `true` | - |

- Returns: `any`
Expand All @@ -3569,9 +3586,9 @@ const target = {
}
]
}
setProperty(target, 'a') // 1
setProperty(target, 'b[0].c') // 2
setProperty(target, () => 'a') // 1
setProperty(target, 'a', 2)
setProperty(target, 'b[0].c', 3)
setProperty(target, () => 'a', 100)
```
- Types:
Expand Down
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "js-cool",
"description": "Collection of common JavaScript / TypeScript utilities",
"version": "5.18.1",
"packageManager": "pnpm@8.9.2",
"version": "5.19.0",
"packageManager": "pnpm@9.0.6",
"main": "dist/index.cjs.js",
"module": "dist/index.esm-bundler.js",
"browser": "dist/index.esm-browser.js",
Expand Down Expand Up @@ -59,12 +59,12 @@
"use-downloads": "^1.5.1"
},
"devDependencies": {
"@babel/core": "^7.24.0",
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-typescript": "^7.23.3",
"@babel/core": "^7.24.4",
"@babel/plugin-transform-runtime": "^7.24.3",
"@babel/preset-env": "^7.24.4",
"@babel/preset-typescript": "^7.24.1",
"@eslint-sets/eslint-config-ts": "^5.12.0",
"@microsoft/api-extractor": "^7.42.3",
"@microsoft/api-extractor": "^7.43.1",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.7",
Expand All @@ -75,29 +75,29 @@
"@rollup/plugin-typescript": "^11.1.6",
"@types/activex-excel": "^14.0.10",
"@types/babel__core": "^7.20.5",
"@types/node": "^20.11.25",
"@types/node": "^20.12.7",
"babel-loader": "^9.1.3",
"core-js": "^3.36.0",
"core-js": "^3.37.0",
"cross-env": "^7.0.3",
"eslint": "^8.57.0",
"fast-glob": "^3.3.2",
"load-yml": "^1.4.0",
"madge": "^6.1.0",
"madge": "^7.0.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"prettier-config-common": "^1.4.0",
"reinstaller": "^3.0.2",
"rm-all": "^1.1.1",
"rollup": "^4.12.1",
"rollup": "^4.16.4",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-polyfill-node": "^0.13.0",
"rollup-plugin-visualizer": "^5.12.0",
"tsnd": "^1.1.0",
"typedoc": "^0.25.11",
"typedoc": "^0.25.13",
"typedoc-plugin-markdown": "^3.17.1",
"typescript": "^5.4.2",
"zx": "^7.2.3"
"typescript": "^5.4.5",
"zx": "^8.0.2"
},
"engines": {
"node": ">=12.20"
Expand Down
Loading

0 comments on commit ca77073

Please sign in to comment.