Skip to content

Commit

Permalink
docs: update design for transflow pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 24, 2021
1 parent 3fd759c commit 9052db8
Showing 1 changed file with 44 additions and 14 deletions.
58 changes: 44 additions & 14 deletions examples/story/0033-mapping-dsl-for-transflow.md
@@ -1,12 +1,20 @@
---
title: mapping dsl for transflow
title: "mapping dsl for transflow"
author:
status: Spike
priority: Low
created_date: 2021-12-23 23:15:25
updated_date: 2021-12-23 23:15:25
updated_date: 2021-12-24 09:44:01
---

## Design Principle

* reuse JavaScript standard library with default value
* alias some method for fun, and can be handle in other function
* pipe syntax for convert

## Pipe map Syntax

default by fields:

```
Expand All @@ -27,9 +35,9 @@ with convert:
blog.title -> title | restrict([length = 150, first = "。", toUppercase])
```

- method for string
- method for int
- method for object
* method for string
* method for int
* method for object

```
blog.id -> id | limit(150) | first("。") | string_to_int
Expand All @@ -45,23 +53,45 @@ size(blog, 150)

methods:

- limit, limit by length
* limit, limit by length

## **Transflow** standard lib

### String handle

```
- first/last(T = string) = split by chars
- first/last(T = number) = split by length
- uppercase/lowercase
- regex(string) = default get first
- replace("a", "b")
- substring()
- trim
```

- int = parseInt
- string = toString
- type system?
### Type Casting

* int = parseInt
* float = parseFloat
* string = toString
* date(str string) = toDate

- date(str string) = toDate
### Math

- sqrt | sin/cos/ = math functional
- regex(string) = default get first
use default JavaScript math library

* sqrt | sin/cos/ = math functional
* fixed (parameter)

### Others

* other custom methods


## Tasks

- other custom methods

1. load custom `transflow.lib.js`
2. Transform DSL

load custom `transflow.lib.js`

0 comments on commit 9052db8

Please sign in to comment.