New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

docuporter

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docuporter - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

8

dist/example/simple.js

@@ -61,7 +61,7 @@ "use strict";

// When traversing a list of object, we may want to report only one item to make an example. We can use the reporter conditions and values to do that. In this case, we only want to mkae reporting for the second person in the list, so we set the condition name to be Jane. Now we can set the value of name to be each of the name of the report, and only when the name matches the condition, the report will take place
rep.conditions.set('name', 'Jane');
rep.setCondition('name', 'Jane');
rep.text('We can now sum all the salaries to get the total amount of money they make together using a reduce function:');
rep.ts(`const totalSalaries = peopleWithSalaries.reduce((acc, person) => acc + person.salary, 0);`);
const totalSalaries = peopleWithSalaries.reduce((acc, person) => {
rep.values.set('name', person.name);
rep.setValue('name', person.name);
// This report will only take place when the name is Jane

@@ -79,4 +79,4 @@ rep.text('During the iterations, we sum up each person salary to the accumulator:');

// Once we are done with the calculation loop, we can clear up the conditions and values so they don't affect the rest of the report
rep.conditions.clearAll();
rep.values.clearAll();
rep.clearConditions();
rep.clearValues();
rep.text('And we get the total salaries:');

@@ -83,0 +83,0 @@ rep.json(totalSalaries);

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

import { KVStore } from './store';
export declare class DocuPorter {
private filePath;
private muted;
values: KVStore;
conditions: KVStore;
private values;
private conditions;
constructor(fileName: string);

@@ -31,2 +30,10 @@ reset(): void;

unMute(): void;
setValue(key: string, value: string): void;
setValues(values: Record<string, string>): void;
clearValue(key: string): void;
clearValues(): void;
setCondition(key: string, value: string): void;
setConditions(conditions: Record<string, string>): void;
clearCondition(key: string): void;
clearConditions(): void;
}

@@ -29,8 +29,7 @@ "use strict";

const fs = __importStar(require("fs"));
const store_1 = require("./store");
class DocuPorter {
constructor(fileName) {
this.muted = false;
this.values = new store_1.KVStore();
this.conditions = new store_1.KVStore();
this.values = new Map();
this.conditions = new Map();
this.text = this.appendText;

@@ -84,3 +83,3 @@ this.json = this.appendJson;

valuesMatch() {
const currentValues = this.values.getAll();
const currentValues = Object.fromEntries(this.values);
return Object.keys(currentValues).every(key => this.match(key));

@@ -99,3 +98,27 @@ }

}
setValue(key, value) {
this.values.set(key, value);
}
setValues(values) {
Object.entries(values).forEach(([key, value]) => this.setValue(key, value));
}
clearValue(key) {
this.values.delete(key);
}
clearValues() {
this.values.clear();
}
setCondition(key, value) {
this.conditions.set(key, value);
}
setConditions(conditions) {
Object.entries(conditions).forEach(([key, value]) => this.setCondition(key, value));
}
clearCondition(key) {
this.conditions.delete(key);
}
clearConditions() {
this.conditions.clear();
}
}
exports.DocuPorter = DocuPorter;
{
"name": "docuporter",
"version": "0.4.1",
"version": "0.5.0",
"description": "Understand a file by documenting it in a markdown file",

@@ -12,3 +12,4 @@ "main": "dist/index.js",

"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc"
"build": "tsc",
"example:simple": "ts-node src/example/simple.ts"
},

@@ -15,0 +16,0 @@ "author": "FrBosquet",

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