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

@jkcfg/std

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jkcfg/std - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9

41

internal/generate.js

@@ -79,7 +79,13 @@ var __rest = (this && this.__rest) || function (s, e) {

}
const isString = s => typeof s === 'string' || s instanceof String;
// Compute the output format of a value.
function valueFormat(o) {
let { file, format } = o;
let { file, format, value } = o;
if (format === undefined || format === std.Format.FromExtension) {
format = formatFromPath(file);
if (isString(value)) {
format = std.Format.Raw;
}
else {
format = formatFromPath(file);
}
}

@@ -143,12 +149,20 @@ return format;

}
/* it's either JSON or YAML */
if (formats[0] !== 'JSON' && formats[0] !== 'YAML') {
error(`stdout output requires either JSON or YAML format but got: ${formats[0]}`);
/*
* If we have more than one file to generate, make sure it's either JSON or
* YAML so we can output a stream of documents.
*/
if (value.length > 1 && formats[0] !== 'JSON' && formats[0] !== 'YAML') {
error(`stdout output for multiple files requires either JSON or YAML format but got: ${formats[0]}`);
return { valid: false, showHelp: false };
}
if (formats[0] === 'JSON') {
stdoutFormat = std.Format.JSONStream;
if (value.length > 1) {
if (formats[0] === 'JSON') {
stdoutFormat = std.Format.JSONStream;
}
else if (formats[0] === 'YAML') {
stdoutFormat = std.Format.YAMLStream;
}
}
else if (formats[0] === 'YAML') {
stdoutFormat = std.Format.YAMLStream;
else {
stdoutFormat = valueFormat(value[0]);
}

@@ -178,4 +192,9 @@ }

if (params.stdout) {
const values = files.map(f => f.value);
std.write(values, '', { format: stdoutFormat });
if (files.length > 1) {
const values = files.map(f => f.value);
std.write(values, '', { format: stdoutFormat });
}
else {
std.write(files[0].value, '', { format: stdoutFormat });
}
}

@@ -182,0 +201,0 @@ else {

@@ -7,3 +7,3 @@ /**

// themselves patched. This is similar to `merge` below, but always
// does does a deep merge.
// does a deep merge on objects, and always replaces other values.
export function patch(obj, patchObj) {

@@ -41,7 +41,10 @@ switch (typeof obj) {

}
// merge transforms `obj` according to the field given in
// `mergeObj`. A field name ending in '+' is "deep merged", that is,
// patched; otherwise, the value of the field is simply assigned into
// the result. Any other fields in `obj` are also assigned in the
// result.
// merge returns a new value which is `a` merged additively with
// `b`. For values other than objects, this means addition (or
// concatenation), with a coercion if necessary.
//
// If both `a` and `b` are objects, there is some fine control over
// each field. If the key in `b` ends with a `+`, the values are
// summed; otherwise, the value is replaced. Any fields in
// `a` and not in `b` are also assigned in the result.
export function merge(a, b) {

@@ -48,0 +51,0 @@ const [typeA, typeB] = [typeof a, typeof b];

{
"name": "@jkcfg/std",
"version": "0.2.8",
"version": "0.2.9",
"description": "jk standard library",

@@ -5,0 +5,0 @@ "main": "std.js",

@@ -20,3 +20,3 @@ # jk

A good way to start with `jk` is to read our [introdution tutorial][quick-start].
A good way to start with `jk` is to read our [introduction tutorial][quick-start].
For more context head to our [introduction blog post][blog-0]!

@@ -23,0 +23,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