Socket
Socket
Sign inDemoInstall

centig

Package Overview
Dependencies
0
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.8 to 1.0.10

lib/__fixtures__/mockSchema.d.ts

9

lib/centig.d.ts

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

export interface IConfigBlock {
export interface ICentigBlock {
type?: ISupportedTypes;

@@ -13,7 +13,6 @@ env?: string;

} | (() => void);
export interface IUserConfigs {
[index: string]: IConfigBlock | IValueTypes | IUserConfigs;
export interface ISchema {
[index: string]: ICentigBlock | IValueTypes | ISchema;
}
export declare const supportedTypes: string[];
declare const centig: <T>(userConfigs: IUserConfigs) => {
declare const centig: <T>(schema: ISchema) => {
get<P extends string | keyof T>(path: P): P extends keyof T ? T[P] : any;

@@ -20,0 +19,0 @@ all(): T;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var validateConfigs_1 = require("./validateConfigs");
var validateSchema_1 = require("./validateSchema");
var prune_1 = require("./prune");
exports.supportedTypes = [
'Number',
'String',
'Boolean',
'Object',
'Array',
'RegExp',
];
var centig = function (userConfigs) {
var errors = validateConfigs_1.default(userConfigs);
var centig = function (schema) {
var errors = validateSchema_1.default(schema);
if (errors.length) {
return throwErrorBeautifully(errors);
throwErrorBeautifully(errors);
}
var prunedConfig = prune_1.default(userConfigs);
var prunedConfig = prune_1.default(schema);
return {

@@ -38,6 +30,12 @@ get: function (path) {

var throwErrorBeautifully = function (errors) {
var output = errors.map(function (errorMessage) { return errorMessage; }).join('\n');
throw Error('\n' + output);
var colorWarning = process.stdout.isTTY ? '\x1b[33;1m' : '';
var colorReset = process.stdout.isTTY ? '\x1b[0m' : '';
var output = errors
.map(function (errorMessage) {
return colorWarning + "\u2718" + colorReset + " " + errorMessage;
})
.join('\n');
throw Error('\n\n' + 'Validation Error \n' + output + '\n');
};
exports.default = centig;
//# sourceMappingURL=centig.js.map

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

import { IUserConfigs } from './centig';
declare const prune: <T>(configs: IUserConfigs) => T;
import { ISchema } from './centig';
declare const prune: <T>(schema: ISchema) => T;
export default prune;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var utils_1 = require("./utils");
var prune = function (configs) {
return Object.keys(configs).reduce(function (accumulator, configName) {
var configBlock = configs[configName];
var prune = function (schema) {
return Object.keys(schema).reduce(function (accumulator, configName) {
var configBlock = schema[configName];
if (utils_1.isObject(configBlock)) {
if (utils_1.isConfigBlock(configBlock)) {
if (utils_1.isCentigBlock(configBlock)) {
var centigConfigBlock = configBlock;

@@ -10,0 +10,0 @@ var value = centigConfigBlock.hasOwnProperty('env')

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

import { IValueTypes, ISupportedTypes, IConfigBlock } from './centig';
import { IValueTypes, ISupportedTypes, ICentigBlock } from './centig';
declare function isConstructor(f: any): boolean;

@@ -6,4 +6,4 @@ declare const isConstructorType: (value: IValueTypes, type: ISupportedTypes) => boolean;

declare const isFunction: (input: any) => boolean;
declare const isConfigBlock: (configBlock: any) => boolean;
declare const hasDuplicateConfigValues: (configBlock: IConfigBlock) => boolean;
export { isConstructor, isConstructorType, isObject, isFunction, isConfigBlock, hasDuplicateConfigValues, };
declare const isCentigBlock: (configBlock: any) => boolean;
declare const hasDuplicateCentigBlockValues: (configBlock: ICentigBlock) => boolean;
export { isConstructor, isConstructorType, isObject, isFunction, isCentigBlock, hasDuplicateCentigBlockValues, };

@@ -22,11 +22,11 @@ "use strict";

exports.isFunction = isFunction;
var isConfigBlock = function (configBlock) {
var isCentigBlock = function (configBlock) {
return (typeof configBlock === 'object' &&
(configBlock.hasOwnProperty('env') || configBlock.hasOwnProperty('value')));
};
exports.isConfigBlock = isConfigBlock;
var hasDuplicateConfigValues = function (configBlock) {
exports.isCentigBlock = isCentigBlock;
var hasDuplicateCentigBlockValues = function (configBlock) {
return (configBlock.hasOwnProperty('env') && configBlock.hasOwnProperty('value'));
};
exports.hasDuplicateConfigValues = hasDuplicateConfigValues;
exports.hasDuplicateCentigBlockValues = hasDuplicateCentigBlockValues;
//# sourceMappingURL=utils.js.map
{
"name": "centig",
"version": "1.0.8",
"version": "1.0.10",
"description": "The Configuration Management library for your JavaScript application",
"main": "lib/centig.js",
"main": "lib/index.js",
"types": "lib/centig.d.ts",

@@ -7,0 +7,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc