-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 0a92e16
Showing
64 changed files
with
2,065 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
theme: jekyll-theme-cayman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [add](./brick-next-pipes.add.md) | ||
|
||
## add() function | ||
|
||
数学加法或字符串拼接。 | ||
|
||
Mathematics | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function add(value: number | string, operand: number | string): number | string; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| value | number \| string | 值。 | | ||
| operand | number \| string | 操作数。 | | ||
|
||
**Returns:** | ||
|
||
number \| string | ||
|
||
如果其中一个参数为字符串,返回字符串,否则返回数字。 | ||
|
||
## Remarks | ||
|
||
详见 [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Addition](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Addition)<!-- -->。 | ||
|
||
## Example | ||
|
||
数学加法: | ||
|
||
```ts | ||
// Number + Number -> addition | ||
1 + 2 // 3 | ||
|
||
// Boolean + Number -> addition | ||
true + 1 // 2 | ||
|
||
// Boolean + Boolean -> addition | ||
false + false // 0 | ||
``` | ||
|
||
字符串拼接: | ||
|
||
```ts | ||
// String + String -> concatenation | ||
'foo' + 'bar' // "foobar" | ||
|
||
// Number + String -> concatenation | ||
5 + 'foo' // "5foo" | ||
|
||
// String + Boolean -> concatenation | ||
'foo' + false // "foofalse" | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [atobUnicode](./brick-next-pipes.atobunicode.md) | ||
|
||
## atobUnicode() function | ||
|
||
支持base64字符解码为中文 | ||
|
||
Logic | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function atobUnicode(value: string): string; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| value | string | 需要进行解码的值 | | ||
|
||
**Returns:** | ||
|
||
string | ||
|
||
解码后的值 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [boolean](./brick-next-pipes.boolean.md) | ||
|
||
## boolean() function | ||
|
||
将一个值转换为布尔值(也可使用别名 `bool`<!-- -->)。 | ||
|
||
Type conversion | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function boolean(value: unknown): boolean; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| value | unknown | 需要转换的值。 | | ||
|
||
**Returns:** | ||
|
||
boolean | ||
|
||
转换后的布尔值。 | ||
|
||
## Remarks | ||
|
||
该转换会把字符串的 `"0"` 也看作 `false`<!-- -->。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [btoaUnicode](./brick-next-pipes.btoaunicode.md) | ||
|
||
## btoaUnicode() function | ||
|
||
支持将中文进行base64编码 | ||
|
||
Logic | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function btoaUnicode(value: string): string; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| value | string | 需要进行编码的值 | | ||
|
||
**Returns:** | ||
|
||
string | ||
|
||
编码后的值 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [cmdbInstanceShowName](./brick-next-pipes.cmdbinstanceshowname.md) | ||
|
||
## cmdbInstanceShowName() function | ||
|
||
获得一个 CMDB 实例的展示名。 | ||
|
||
Others | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function cmdbInstanceShowName(value: string | string[]): string; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| value | string \| string\[\] | 用于展示的(一个或多个)属性值。 | | ||
|
||
**Returns:** | ||
|
||
string | ||
|
||
实例的展示名。 | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
cmdbInstancesShowName("Foo") | ||
// Returns "Foo". | ||
|
||
cmdbInstancesShowName(["Foo", "Bar"]) | ||
// Returns "Foo(Bar)". | ||
|
||
cmdbInstancesShowName(["Foo", "Bar", "Baz"]) | ||
// Returns "Foo(Bar, Baz)". | ||
|
||
cmdbInstancesShowName(["Foo"]) | ||
// Returns "Foo". | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [countBy](./brick-next-pipes.countby.md) | ||
|
||
## countBy() function | ||
|
||
统计一个集合中每个元素的指定属性(或迭代器执行结果)的值出现的次数。 | ||
|
||
Collection | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function countBy(collection: unknown[] | Record<string, unknown>, iteratee: string | number): Record<string, number>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| collection | unknown\[\] \| Record<string, unknown> | 数据集合。 | | ||
| iteratee | string \| number | 属性名(或迭代器)。 | | ||
|
||
**Returns:** | ||
|
||
Record<string, number> | ||
|
||
统计结果。 | ||
|
||
## Remarks | ||
|
||
透传调用 [\_.countBy](https://lodash.com/docs/#countBy)<!-- -->。 | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
countBy([6.1, 4.2, 6.3], Math.floor); | ||
// => { '4': 1, '6': 2 } | ||
|
||
countBy(['one', 'two', 'three'], 'length'); | ||
// => { '3': 2, '5': 1 } | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [datetime](./brick-next-pipes.datetime.md) | ||
|
||
## datetime() function | ||
|
||
日期时间格式化(使用当地时区)。 | ||
|
||
Datetime | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function datetime(value: number | string, format: string): string; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| value | number \| string | 日期时间字符串或 Unix 时间戳([https://momentjs.com/docs/\#/parsing/string/](https://momentjs.com/docs/#/parsing/string/)<!-- -->)。 | | ||
| format | string | 输出格式。 | | ||
|
||
**Returns:** | ||
|
||
string | ||
|
||
格式化后的日期时间。 | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
datetime(1582877669000, "YYYY-MM-DD") | ||
// Returns "2020-02-28" | ||
|
||
datetime("2020-02-28T17:14", "YYYY-MM-DD") | ||
// Returns "2020-02-28" | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [deltaTime](./brick-next-pipes.deltatime.md) | ||
|
||
## deltaTime() function | ||
|
||
将一个时间段转换为人类可读的文本。 | ||
|
||
Datetime | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function deltaTime(time: number | string | Period, withSuffix?: boolean, format?: string): string; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| time | number \| string \| [Period](./brick-next-pipes.period.md) | 指定时间(字符串或 UNIX 时间戳)或时间段。 | | ||
| withSuffix | boolean | 是否添加后缀(默认为 <code>true</code>)。 | | ||
| format | string | 输入的时间格式(使用时间戳时可忽略,默认为 <code>"YYYY-MM-DD HH:mm:ss"</code>)。 | | ||
|
||
**Returns:** | ||
|
||
string | ||
|
||
人类可读的时间段显示。 | ||
|
||
## Remarks | ||
|
||
给定一个时间段(`startTime` 和 `endTime`<!-- -->),将它转换为人类可读的文本。 | ||
|
||
当输入时间为单个值时,则计算它与当前时间的间隔时间段。 | ||
|
||
## Example | ||
|
||
|
||
```ts | ||
// Assuming now is "2019-05-10 17:51:00". | ||
|
||
deltaTime("2019-05-10 17:21:00") | ||
// Returns "30 minutes ago" | ||
|
||
deltaTime("2019-05-10 18:51:00") | ||
// Returns "in an hour" | ||
|
||
deltaTime({ startTime: "2019-05-10", endTime: "2019-06-10" }, false) | ||
// Returns "a month" | ||
|
||
deltaTime({ startTime: "2019-05-10 17:48:00" }, false) | ||
// Returns "3 minutes" | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@easyops-cn/brick-next-pipes](./brick-next-pipes.md) > [divide](./brick-next-pipes.divide.md) | ||
|
||
## divide() function | ||
|
||
数学除法。 | ||
|
||
Mathematics | ||
|
||
**Signature:** | ||
|
||
```typescript | ||
export declare function divide(value: number, operand: number): number; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| value | number | 被除数。 | | ||
| operand | number | 除数。 | | ||
|
||
**Returns:** | ||
|
||
number | ||
|
||
商。 | ||
|
Oops, something went wrong.