npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lib-match

v1.1.10

Published

一个应用于前后端完全分离时代下的字段映射库

Downloads

39

Readme

Intro 介绍

一个用于前后端完全分离的字段映射库,使得前端的数据格式定义完全脱离后端的限制,做到真正的前后端完全分离。同时可用于解决复杂字段的处理场景,致力于一次 match,完全转换,让 data 层的处理更加有序。

  • 减少代码量,一次 match,解决复杂场景。
  • 丰富的 api,不仅支持常规对象匹配,数组对象匹配,还提供默认值,自定义 function。同时可配置多样的 config 来实现特殊字符过滤,相同字段直接补全等功能。

ps: 配合 es6 语法代码真的可以很简洁。

Scenario 使用场景

  • 相同 ui,不同接口:相同的页面展示,数据来源多方。让 ui 兼容不同的数据格式的成本比较大,而且在模板中增加针对不同数据的兼容会降低模块的可读性,match 可以使得不同的数据结构最后都能生成相同格式的数据。

  • 复杂的数据层中间件,复杂的数据场景:使用 match,一次转换让数据层之间的数据传递更清晰透明。

  • 前后端完全分离,并且前端先于后端开发:前端在开发过程中可以自定义页面所需数据结构,待后端接口给出后,再通过 match 转化为对应的结构即可。(talk less, code more)

Installation 安装

npm install lib-match --save-dev

Advantage 优势

  • 兼容普通对象与数组对象与数组的映射
  • 支持多对一的映射(多个映射 params,一个 match 输出)
  • 支持 function 映射(功能强大)
  • 支持映射结果带有默认值 并可区分默认值的数据类型
  • 支持映射结果数据类型转换(int float string boolean Boolean)
  • 支持注册全局函数
  • 支持过滤、自动补全、关键词忽略的 config 配置

Usage 使用方法

API