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

@choiceform/os-editor-mini-parser

v0.0.7

Published

choice form survey editor mini parser

Downloads

20

Readme

v0.0.5

这里是为简化版编辑器抽取出来的类型规范和一个数据兼容模块

设计变化:

一开始设计的时候,我们把简易版的数据结构设计成专业版的子集,后来经尝试发现,这样做仍然会让简易版中需要过多地组织和自己无关的数据结构,所以决定把简易版的数据在简化一下,同时命名属性也可以不同,命名称适应于简易版的名称,易于理解。

除了节点的UUID和选项的UUID是必须的,和简易版无关的其他属性都可以不出现在简易版的数据结构中,

这个包主要提供两个作用:

  1. 提供简易版问卷payload的类型规范,方便写代码的时候参考,保证导出的payload数据格式的正确。
  2. 提供一个简易版payload与完整版payload的相互转化的处理模块,因为简易版编辑器的功能是完整版的一个极小的子集,它关心的功能很少,所以简易版payload和完整版的payload相比,缺少一些必须的内容,这些内容与简易版毫无关系,不应该由简易版负责补足,所以提供一对封装好的方法去处理两个版本之间的数据补足或剔除
    • 简易版中保存问卷前调用补足方法得到完整版数据再保存。
    • 简易版中加载问卷后调用剔除方法得到精简版数据再使用。

关于上述的考虑,之前有两个想法,此处留作笔记:

  1. 可以让答题端和后台都去将这些属性读取过程都进行判断保护,但是两方都要改很多属性;
  2. 还有一个方法就是提交前进行填补处理,把确实的属性默认值都填补上去,而需要填补什么东西对于简易版编辑的开发者来说是无需知道的,是完整编辑器和抽出简易版类型规范的开发者的责任,所以同时在这个包里面发布一个填补包,简易编辑器开发者使用这个包的方法处理一下payload再保存即可。 综合考虑,我门选择了第二种方式。

安装

yarn add @choiceform/os-editor-mini-parser
# 或者
npm install @choiceform/os-editor-mini-parser

使用

使用兼容填补方法:

import {patch} from '@choiceform/os-editor-mini-parser';

// 以下的exportSurveyJson、gzip、base64和savePayload都是用于举例的虚拟方法,真实场合换成自己的真实方法。

// 简易版中使用自己的方法导出的问卷数据json对象,exportSurveyJson
const surveyJson = exportSurveyJson();

// 由于这是个简化版的,我们兼容填补一下,具体原因请看上面的说明
const compatSurveyJson = patch(surveyJson);
// 压缩处理
const gzipped = gzip(JSON.stringify(compatSurveyJson));
const base64Encoded = base64(gzipped);
// 调用保存方法保存到后台
savePayload(base64Encoded);