Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pushrocks/smartjson

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pushrocks/smartjson - npm Package Compare versions

Comparing version 2.0.2 to 3.0.0

dist/smartjson.plugins.d.ts

10

dist/index.d.ts

@@ -1,2 +0,6 @@

export declare class Foldable {
/// <reference types="fast-json-stable-stringify" />
import * as plugins from './smartjson.plugins';
export declare class Smartjson {
static parse: (text: string, reviver?: (key: any, value: any) => any) => any;
static stringify: typeof plugins.stableJson;
saveableProperties: string[];

@@ -6,3 +10,5 @@ /**

*/
foldToObject(): {};
foldToObject(): {
[key: string]: any;
};
/**

@@ -9,0 +15,0 @@ * enfolds data from an object

15

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
let lodash = require('lodash');
class Foldable {
const plugins = require("./smartjson.plugins");
class Smartjson {
/**

@@ -11,3 +11,3 @@ * folds a class into an object

for (let keyName of this.saveableProperties) {
newFoldedObject[keyName] = lodash.cloneDeep(this[keyName]);
newFoldedObject[keyName] = plugins.lodash.cloneDeep(this[keyName]);
}

@@ -27,3 +27,8 @@ return newFoldedObject;

}
exports.Foldable = Foldable;
// ======
// STATIC
// ======
Smartjson.parse = JSON.parse;
Smartjson.stringify = plugins.stableJson;
exports.Smartjson = Smartjson;
/**

@@ -40,2 +45,2 @@ * Decorator that marks a property as foldable

};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLElBQUksTUFBTSxHQUFHLE9BQU8sQ0FBQyxRQUFRLENBQUMsQ0FBQztBQUUvQixNQUFhLFFBQVE7SUFHbkI7O09BRUc7SUFDSCxZQUFZO1F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DQUFDLGtCQUFrQixDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQztJQUN0QyxDQUFDLENBQUM7QUFDSixDQUFDLENBQUMifQ==
{
"npmci": {
"npmAccessLevel": "public"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartjson",
"shortDescription": "typed json handlers",
"npmPackagename": "@pushrocks/smartjson",
"license": "MIT"
}
}
}
{
"name": "@pushrocks/smartjson",
"version": "2.0.2",
"version": "3.0.0",
"private": false,

@@ -23,11 +23,13 @@ "description": "typed json handlers",

"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsrun": "^1.1.12",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.1",
"@types/node": "^10.9.4"
"@gitzone/tsbuild": "^2.1.8",
"@gitzone/tsrun": "^1.1.17",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^11.9.4"
},
"dependencies": {
"lodash": "^4.17.10"
"@types/fast-json-stable-stringify": "^2.0.0",
"fast-json-stable-stringify": "^2.0.0",
"lodash": "^4.17.11"
}
}

@@ -1,22 +0,17 @@

# smartjson
# @pushrocks/smartjson
typed json handlers
## Availabililty
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartjson)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartjson)
* [github.com (source mirror)](https://github.com/pushrocks/smartjson)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartjson/)
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartjson)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartjson)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartjson)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartjson/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartjson/badges/master/build.svg)](https://GitLab.com/pushrocks/smartjson/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartjson/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartjson/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartjson.svg)](https://www.npmjs.com/package/smartjson)
[![Dependency Status](https://david-dm.org/pushrocks/smartjson.svg)](https://david-dm.org/pushrocks/smartjson)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartjson/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartjson/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartjson/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartjson)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![build status](https://gitlab.com/pushrocks/smartjson/badges/master/build.svg)](https://gitlab.com/pushrocks/smartjson/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartjson/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartjson/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartjson.svg)](https://www.npmjs.com/package/@pushrocks/smartjson)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartjson/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartjson)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

@@ -33,5 +28,8 @@

```javascript
import { Foldable, foldDec } from 'smartjson';
import { Smartjson, foldDec } from 'smartjson';
class AwesomeClass extends Foldable {
class AwesomeClass extends Smartjson {
static stringify
computedValue: string;

@@ -52,7 +50,7 @@

For further information read the linked docs at the top of this README.
For further information read the linked docs at the top of this readme.
> MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

@@ -1,7 +0,7 @@

import { tap, expect } from "@pushrocks/tapbundle";
import { tap, expect } from '@pushrocks/tapbundle';
import { Foldable, foldDec } from "../ts/index";
import { Smartjson, foldDec } from '../ts/index';
class SomeClass extends Foldable {
@foldDec() thisis: string = "test";
class SomeClass extends Smartjson {
@foldDec() thisis: string = 'test';
constructor() {

@@ -15,22 +15,22 @@ super();

tap.test("should create a Foldable extended instance", async () => {
tap.test('should create a Foldable extended instance', async () => {
mySomeClass = new SomeClass();
expect(mySomeClass).to.be.instanceof(SomeClass);
expect(mySomeClass).to.be.instanceof(Foldable);
expect(mySomeClass).to.be.instanceof(Smartjson);
});
tap.test("should create a folded object", async () => {
tap.test('should create a folded object', async () => {
let foldedObject = mySomeClass.foldToObject();
expect(foldedObject)
.property("thisis")
.to.equal("test");
.property('thisis')
.to.equal('test');
});
tap.test("should enfold from object", async () => {
mySomeClass.enfoldFromObject({ thisis: "test2" });
tap.test('should enfold from object', async () => {
mySomeClass.enfoldFromObject({ thisis: 'test2' });
expect(mySomeClass)
.property("thisis")
.to.equal("test2");
.property('thisis')
.to.equal('test2');
});
tap.start()
tap.start();

@@ -1,4 +0,15 @@

let lodash = require('lodash');
import * as plugins from './smartjson.plugins';
export class Foldable {
export class Smartjson {
// ======
// STATIC
// ======
static parse = JSON.parse;
static stringify = plugins.stableJson;
// ========
// INSTANCE
// ========
saveableProperties: string[];

@@ -10,5 +21,5 @@

foldToObject() {
let newFoldedObject = {};
let newFoldedObject: {[key: string]: any} = {};
for (let keyName of this.saveableProperties) {
newFoldedObject[keyName] = lodash.cloneDeep(this[keyName]);
newFoldedObject[keyName] = plugins.lodash.cloneDeep(this[keyName]);
}

@@ -15,0 +26,0 @@ return newFoldedObject;

{
"extends": "tslint-config-standard"
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc