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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jsam

v1.3.3

Published

一个图状数据序列化工具

Readme

JSAM

JSAM为efront内置的一个工具,考虑到较为常用,将其独立发布。

JSAM提供了一种js内存对象序列化的一种方式,支持将存在环形引用的图状数据转换成字符串,或将转换后的字符串按其原有结构还原为内存数据。

目前支持function类型以外的几乎所有类型,其使用方法与JSON的使用方法类似

    // JSAM序列化对象举例
    var o = {};
    o.o = o;
    JSAM.stringify(o); // {1:0},"o"
    JSAM.stringify(null) // null
    JSAM.stringify(undefined); // 空字符串
    JSAM.stringify(1); // 1
    JSAM.stringify(true); // true
    JSAM.stringify(false); // false
    JSAM.stringify(NaN); // NaN
    JSAM.stringify(Infinity); // Infinity
    JSAM.stringify({}) // {}
    JSAM.stringify([]) // []
    JSAM.stringify(""); // ""
    JSAM.stringify("\"\\"); // "\"\\"
    JSAM.stringify(/a/); // /a/
    JSAM.stringify(/a/ig); // /a/gi
    JSAM.stringify(/a[/]/ig); // /a[\/]/gi
    JSAM.stringify(new Date); // 2020-08-16T07:07:43.652Z
    JSAM.stringify(BigInt("9007199254740993")); // 9007199254740993
    JSAM.stringify(Symbol("a(")); // 'a('
    JSAM.stringify(Symbol("asd")); // 'asd'
    JSAM.stringify(Symbol("as'd")); // 'as\'d'
    JSAM.stringify([2]) // [1],2
    JSAM.stringify([""]) // [1],""
    JSAM.stringify([{}]) // [1],{}
    JSAM.stringify([{ a: undefined }]) // [1],{2:3},"a",
    JSAM.stringify({ a: undefined }) // {1:2},"a",
    JSAM.stringify([undefined]) // [1],
    JSAM.stringify([true]) // [1],true
    JSAM.stringify({ a: false }) // {1:2},"a",false
    JSAM.stringify({ a: null }) // {1:2},"a",null
    JSAM.stringify({ a: 0 }) // {1:2},"a",0
    JSAM.stringify({ a: NaN }) // {1:2},"a",NaN
    JSAM.stringify({ a: { b: { c: [3], d: [2] } } }) // {1:2},"a",{3:4},"b",{5:6,7:8},"c",[9],"d",[10],3,2
    JSAM.stringify({ a: { b: { c: [3, o], d: [2] } } }) //{1:2},"a",{3:4},"b",{5:6,7:8},"c",[9,10],"d",[11],3,{12:10},2,"o"
    var a = {};
    b = { a };
    c = [b],
    d = { c };
    a.d = d;
    JSAM.stringify(a); // {1:2},"d",{3:4},"c",[5],{6:0},"a"

用法2

  • 可以通过第二个参数传入一组对象,与这些对象中的一个相匹配的数据将使用数字代替,反序列化时请传入完全相同的一组对象
    var obj={
        k1:obj1,
        k2:[obj2],
        k3:[],
        k4:{k5:obj3},
        ...
    };
    var str = JSAM.stringify(obj,[obj1,obj2,obj3,...]);
    var obj = JSAM.parse(str,[obj1,obj2,obj3,...]);
  • 第二个参数内也可以传入构造方法,由这些构造方法生成的数据将使用数字记忆它的构造方法,反序列化时请传入完全相同的参数
    var obj = {
        k1: new f1,
        k2: [new f2],
        k3: {k4:new f3},
        ...
    };
    var str = JSAM.stringify(obj,[f1,f2,f3,...]);
    var obj = JSAM.parse(str,[f1,f2,f3,...]);