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

rapid-inquirer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rapid-inquirer - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

37

fromObject.js
function promptsToBuildObject(obj, options) {
var answers;
if(!options) {

@@ -8,6 +9,8 @@ options = {};

var keys = Object.keys(obj);
var subObjects = [];
keys.forEach(key => {
var buildFieldPrompt = function(target, key, layerOptions) {
var type, promptType;
var val = obj[key];
var skipKey = false;
var val = target[key];
if(val === undefined || val === null) {

@@ -29,2 +32,5 @@ type = "string"; // No value defaults to string

} else if(typeof val === "object" || val instanceof Object) {
skipKey = true;
subObjects.push({ key: key, obj: val });
} else {

@@ -36,7 +42,7 @@ type = "string";

if(!options.onlyEmptyFields || type === "boolean" || val === undefined || val === null || val === '') {
if(!skipKey && (!layerOptions.onlyEmptyFields || type === "boolean" || val === undefined || val === null || val === '')) {
var p = {
type: promptType,
name: key,
message: options.fieldPrefix ? `${options.fieldPrefix}.${key}: ` : `${key}: `
message: layerOptions.fieldPrefix ? `${layerOptions.fieldPrefix}.${key}: ` : `${key}: `
};

@@ -48,6 +54,17 @@ if(val !== undefined && val !== null && val !== "") {

}
};
keys.forEach(key => {
buildFieldPrompt(obj, key, options);
});
return this.prompt(prompts)
.then(answers => {
.then(results => {
answers = results;
return Promise.all(subObjects.map(sub => {
return buildNestedObject.call(this, answers, sub.key, sub.obj, options);
}));
})
.then(() => {
return answers;

@@ -57,2 +74,12 @@ });

function buildNestedObject(answers, key, nestedObj, options) {
var fieldPrefix = options.fieldPrefix ? `${options.fieldPrefix} ${key}` : `${key} `;
var nestedOptions = Object.assign({}, options, { fieldPrefix: fieldPrefix });
return this.promptsToBuildObject(nestedObj, nestedOptions)
.then(results => {
answers[key] = results;
return answers;
});
}
module.exports = promptsToBuildObject;

2

package.json
{
"name": "rapid-inquirer",
"version": "0.0.1",
"version": "0.0.2",
"description": "Streamline extension for inquirer to have less overhead",

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

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