# jear

> jsonify for velocity

Latest version **0.1.4** (published 2013-08-26) · 0 weekly downloads

## Install

```sh
npm install jear
pnpm add jear
yarn add jear
bun add jear
```

Provides the command `jear`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.4 |
| Published | 2013-08-26 |
| First published | 2013-02-20 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10 |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+6 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | shepherdwind |
| Maintainers | shepherdwind |

## Links

- npm: https://www.npmjs.com/package/jear
- Repository: https://github.com/shepherdwind/jear
- Issues: https://github.com/shepherdwind/jear/issues
- npm.io page: https://npm.io/package/jear

## Dependencies (4)

- [debug](https://npm.io/package/debug.md) ~0.7.2
- [shelljs](https://npm.io/package/shelljs.md) ~0.1.4
- [commander](https://npm.io/package/commander.md) ~2.0.0
- [velocityjs](https://npm.io/package/velocityjs.md) ~0.3.15

## Recent versions

- 0.1.4 (latest) — 2013-08-26
- 0.1.3 — 2013-08-25
- 0.1.2 — 2013-08-23
- 0.1.1 — 2013-08-22
- 0.1.0 — 2013-02-20

## README

# jear

jsonify for velocity

## 基本原理与过程

基本原理，从一个vm文件a.vm中，依次读取所有变量，生成一个结构化的a.mock.vm，在a.vm
底部，引用a.mock.vm

```
<!--
#parse('path/to/a.mock.vm')
-->
```

通过开发的服务器，可以在html注释中得到一些准备好的数据，如下形式

```
<!--
@@@review
{
  "@@!reasonFlag": "{{{false}}}",
  "@@!caseId": "{{{4001308230000001}}}",
  "@@tbToken.getAjaxUniqueToken()": "{{{5bb5de1e764ee}}}",
  "@@!{myserviceModule.setTarget(==json/createMessage.vm==)}": "{{{http://support.daily.taobao.net/myservice/json/create_message.htm}}}"
}@@@
-->
```

通过执行`jear -p xx.html`可以得到json结构的数据，这些构成本地demo的模拟数据:

```json
{
  "$!reasonFlag": false,
  "$!caseId": "4001308230000001",
  "$tbToken.getAjaxUniqueToken()": "5bb5de1e764ee",
  "$!{myserviceModule.setTarget(\"json/createMessage.vm\")}": "http://support.daily.taobao.net/myservice/json/create_message.htm"
}
```

这种方案，不考虑vm模板变量运算过程，只关注vm执行过程的输入和输出。

- 输入: 指一个vm变量的表示形式，对于$a.b，输入即字符串'$a.b'
- 输出: 开发通过java元算得到的结果

正常情况下，变量读取是从对象查找过程，velocityjs在查找变量之前，首先对比jear提供
的map，如果变量所对应的字符串存在于map中，直接返回结果。

问题解决描述为，我们知道$a.b.c()的结果，在本地模拟过程，我们不需要知道$a对应的变
量，我们最终只需要知道$a.b.c()的结果。开发vm中的所有变量求值过程，可以看做一堆
函数运算，我们知道函数描述和函数的输出，但函数运算过程有无数种可能，这个过程是
无法模拟，但是模拟运算过程，也是为了得到最终的结果。

## Started

Install the module with: `npm install jear`

```sh
  Usage: jear [option] <file.vm>

  Options:

    -h, --help               output usage information
    -V, --version            output the version number
    -o, --output <filename>  out put filename
    -p, --parseJSON          parse html, get json data

  Examples:

    $ jear xx.vm
    $ jear -p xx.html
    $ #pase xx.html to a.json
    $ jear -p -o a.json xx.html

```
## License
Copyright (c) 2013 shepherdwind  
Licensed under the MIT license.

---
_Source: https://npm.io/package/jear · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
