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

ftconfig

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ftconfig - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

4

dist/adapter.d.ts
import { IAdapter } from "./adapter.d";
export declare const json: IAdapter;
export declare const yaml: IAdapter;
export declare const ini: IAdapter;
export declare const toml: IAdapter;
export declare const json5: IAdapter;
export declare const hjson: IAdapter;
export declare const raw: IAdapter<string>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const TOML = require("@iarna/toml");
const HJSON = require("hjson");
const INI = require("ini");
const YAML = require("js-yaml");
const JSON5 = require("json5");
exports.json = {

@@ -30,2 +34,54 @@ parse: (str) => {

};
exports.ini = {
parse: (str) => {
try {
return INI.parse(str);
}
catch (error) {
return null;
}
},
stringify: (obj, options) => {
return INI.stringify(obj) + "\n";
}
};
exports.toml = {
parse: (str) => {
try {
return TOML.parse(str);
}
catch (error) {
return null;
}
},
stringify: (obj, options) => {
return TOML.stringify(obj) + "\n";
}
};
exports.json5 = {
parse: (str) => {
try {
return JSON5.parse(str);
}
catch (error) {
return null;
}
},
stringify: (obj, options = { indent: 2 }) => {
return JSON5.stringify(obj, null, options.indent) + "\n";
}
};
exports.hjson = {
parse: (str) => {
try {
return HJSON.parse(str);
}
catch (error) {
return null;
}
},
stringify: (obj, options = { indent: 2 }) => {
return HJSON.stringify(obj, { space: options.indent }) + "\n";
}
};
exports.raw = {

@@ -32,0 +88,0 @@ parse: (str) => str,

@@ -42,2 +42,18 @@ "use strict";

value: "yaml"
},
{
match: /\.ini$/,
value: "ini"
},
{
match: /\.toml$/,
value: "toml"
},
{
match: /\.json5$/,
value: "json5"
},
{
match: /\.hjson$/,
value: "hjson"
}

@@ -44,0 +60,0 @@ ];

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const makeDir = require("make-dir");
const path = require("path");
const adapters = require("./adapter");

@@ -25,2 +27,5 @@ class WriteConfig {

if (options.path && options.encoding) {
if (!fs.existsSync(path.dirname(options.path))) {
makeDir.sync(path.dirname(options.path));
}
const data = this.toString(options);

@@ -27,0 +32,0 @@ fs.writeFileSync(options.path, data, {

@@ -1,3 +0,6 @@

import * as fs from "fs";
import TOML = require("@iarna/toml");
import HJSON = require("hjson");
import INI = require("ini");
import YAML = require("js-yaml");
import JSON5 = require("json5");
import { IAdapter } from "./adapter.d";

@@ -31,2 +34,54 @@

export const ini: IAdapter = {
parse: (str) => {
try {
return INI.parse(str);
} catch (error) {
return null;
}
},
stringify: (obj, options?) => {
return INI.stringify(obj) + "\n";
}
};
export const toml: IAdapter = {
parse: (str) => {
try {
return TOML.parse(str);
} catch (error) {
return null;
}
},
stringify: (obj, options?) => {
return TOML.stringify(obj) + "\n";
}
};
export const json5: IAdapter = {
parse: (str) => {
try {
return JSON5.parse(str);
} catch (error) {
return null;
}
},
stringify: (obj, options = { indent: 2 }) => {
return JSON5.stringify(obj, null, options.indent) + "\n";
}
};
export const hjson: IAdapter = {
parse: (str) => {
try {
return HJSON.parse(str);
} catch (error) {
return null;
}
},
stringify: (obj, options = { indent: 2 }) => {
return HJSON.stringify(obj, { space: options.indent }) + "\n";
}
};
export const raw: IAdapter<string> = {

@@ -33,0 +88,0 @@ parse: (str) => str,

20

lib/index.ts

@@ -8,6 +8,2 @@ import * as fs from "fs";

interface IAnyObject {
[key: string]: any;
}
export const read = <T = any>(data: string, options: string | IReadOptions) => {

@@ -52,2 +48,18 @@ if (typeof options === "string") {

value: "yaml"
},
{
match: /\.ini$/,
value: "ini"
},
{
match: /\.toml$/,
value: "toml"
},
{
match: /\.json5$/,
value: "json5"
},
{
match: /\.hjson$/,
value: "hjson"
}

@@ -54,0 +66,0 @@ ];

export interface IReadFileOptions extends IReadOptions {
encoding: string;
encoding?: string;
}

@@ -4,0 +4,0 @@

import * as fs from "fs";
import makeDir = require("make-dir");
import * as path from "path";
import * as adapters from "./adapter";

@@ -36,2 +38,5 @@ import { IAdapter } from "./adapter.d";

if (options.path && options.encoding) {
if (!fs.existsSync(path.dirname(options.path))) {
makeDir.sync(path.dirname(options.path));
}
const data = this.toString(options);

@@ -38,0 +43,0 @@ fs.writeFileSync(options.path, data, {

{
"name": "ftconfig",
"version": "1.0.0",
"version": "1.1.0",
"description": "F*ck the config",

@@ -21,3 +21,14 @@ "main": "dist/index.js",

"arylo",
"typescript"
"typescript",
"config",
"easy-to-use",
"parser",
"serializer",
"json",
"yml",
"yaml",
"ini",
"toml",
"json5",
"hjson"
],

@@ -47,2 +58,5 @@ "engines": {

"@types/find-up": "^2.1.1",
"@types/hjson": "^2.4.0",
"@types/ini": "^1.3.30",
"@types/json5": "0.0.30",
"@types/make-dir": "^1.0.3",

@@ -60,3 +74,2 @@ "@types/node": "^10.1.2",

"lint-staged": "^7.3.0",
"make-dir": "^1.3.0",
"prettier": "^1.14.3",

@@ -68,4 +81,9 @@ "rimraf": "^2.6.2",

"dependencies": {
"js-yaml": "^3.12.0"
"@iarna/toml": "^2.2.1",
"hjson": "^3.1.2",
"ini": "^1.3.5",
"js-yaml": "^3.12.0",
"json5": "^2.1.0",
"make-dir": "^1.3.0"
}
}
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