67168843dda5a1972a3a2b0a3e4ebba5 中文文档教程

发布于 8年前 浏览 23 项目主页 更新于 3年前

PropertyMaper Build StatusCoverage Status

JavaScript 中的模块,用于将对象的属性映射为字符串键的属性作为值

Prerequisites

要安装和运行项目,您需要安装 NodeJS。

https://nodejs.org/en

Installation

npm install 67168843dda5a1972a3a2b0a3e4ebba5

Usage

将对象映射到 json 字符串模板:

.map(map, scope)

参数:map(string) 包含json格式的字符串模板

参数:scope(object) 包含具有要绑定到地图中的数据的对象

返回: 具有地图格式

Example

var pm = require('67168843dda5a1972a3a2b0a3e4ebba5');

var result = pm.map("{
    name:data.person.name,
    last_name:data.person.last_name,
    addres:data.person.addres,
    hobbies:data.person.hobbies,
    others:data.others.other
  }",
  {
    data: {
      person: {
        name:"Carlos",
        last_name:"Linares",
        addres:"Guadalajara",
        hobbies:"Play Guitar, Video Games"
      },
      others: {
        other: "Other things, etc."
      }
    }
  }
);

console.log(result);

Result

的映射对象结果将是……

{
  name:"Carlos",
  last_name:"Linares",
  addres:"Guadalajara",
  hobbies:"Play Guitar, Video Games",
  others:"Other things, etc."
}

License

麻省理工学院许可证

PropertyMaper Build StatusCoverage Status

Module in JavaScript for map object's properties to string key's properties as values

Prerequisites

To Install and run the project you need to have installed NodeJS.

https://nodejs.org/en

Installation

npm install 67168843dda5a1972a3a2b0a3e4ebba5

Usage

To map an object to a json-string template:

.map(map, scope)

Parameter: map(string) Contains the string template in json format

Parameter: scope(object) Contains the object wich has the data to bind into map

Return: Maped object with map format

Example

var pm = require('67168843dda5a1972a3a2b0a3e4ebba5');

var result = pm.map("{
    name:data.person.name,
    last_name:data.person.last_name,
    addres:data.person.addres,
    hobbies:data.person.hobbies,
    others:data.others.other
  }",
  {
    data: {
      person: {
        name:"Carlos",
        last_name:"Linares",
        addres:"Guadalajara",
        hobbies:"Play Guitar, Video Games"
      },
      others: {
        other: "Other things, etc."
      }
    }
  }
);

console.log(result);

Result

The result will be…

{
  name:"Carlos",
  last_name:"Linares",
  addres:"Guadalajara",
  hobbies:"Play Guitar, Video Games",
  others:"Other things, etc."
}

License

MIT License

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文