serde_json::Value with lodash.js spec, makes life easier.
Cargo.toml
toml
[dependencies]
serde_json = "*"
serde_json_lodash = "0.1"
main.rs
```rs
use serdejson::json; fn main() { asserteq!( capitalize!(json!("FRED")), json!("Fred") ); } ```
macro
, 1 fn
:
macro
should be exactly same api as lodash.js version. (the main inputs and return value should only be serde_json::Value
or std::ops::Fn
)capitalize!(Value) -> Value
fn
capitalize(Value) -> Value
_.chunk(array, [size=1])
=> ::check(json!([1,2,3]), 2)
, size should be usize
, not Value::Number
_.get(object, path, [defaultValue])
, the ported version fn should be ::get(object, path, defaultValue)
, no optional_.merge(object, [...sources])
, the ported version fn should be ::merge(object, source)
, no more optionalsfn
with x_
prefix: input is not Valuex_capitalize(&str) -> Value
fn
with _x
suffix: output is not Valuecapitalize_x(Value) -> String
fn
with both x_
and _x
x_capitalize_x(&str) -> &str
_.merge({a:1}, {b:2})
, _.merge([1], [2])
, we don't know which type should be for, so we don't implementExamples:
section should be exactly same as the examples in lodash doc. If we need more examples, they should be put in the More Examples:
sectionMore examples
section, we relied on rust's powerful doc testing```bash
cargo watch -x "test" -w "Cargo.toml" -w "src"
./lint.sh
cargo bump patch --git-tag # same as npm version
```
verify lodash.js api
```console $ npm i $ node Welcome to Node.js v15.14.0. Type ".help" for more information.
const l = require('lodash') undefined l.toString() ''
```