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

httpsnippet

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

httpsnippet - npm Package Compare versions

Comparing version 1.0.0-beta.1 to 1.0.0-beta.2

src/targets/node/index.js

2

package.json
{
"version": "1.0.0-beta.1",
"version": "1.0.0-beta.2",
"name": "httpsnippet",

@@ -4,0 +4,0 @@ "description": "HTTP Request snippet generator for *most* languages",

@@ -111,3 +111,3 @@ # HTTP Snippet [![version][npm-version]][npm-url] [![License][npm-license]][license-url]

// generate cURL output
console.log(snippet.curl({
console.log(snippet.convert('curl', {
indent: '\t';

@@ -117,3 +117,6 @@ }));

// generate nodeJS output
console.log(snippet.nodejs());
console.log(snippet.convert('node'));
// generate PHP output
console.log(snippet.convert('php', 'curl'));
```

@@ -141,7 +144,8 @@

return {
key: 'node', // target key
family: 'node', // target family
key: 'native', // target key
ext: '.js', // preferred extension
title: '', // target label
description: '' // target description
}
};
};

@@ -148,0 +152,0 @@ ```

@@ -63,7 +63,53 @@ 'use strict';

// add each target as a prototype
for (var lang in targets) {
HTTPSnippet.prototype[lang] = targets[lang];
}
HTTPSnippet.prototype.convert = function (family, target, opts) {
if (!opts && target) {
opts = target;
}
var func = this._matchTarget(family, target);
if (func) {
return func.call(this, opts);
}
return false;
};
HTTPSnippet.prototype._matchTarget = function (familyName, target) {
// does it exist?
if (targets[familyName] === undefined) {
return false;
}
// isolate the family
var family = targets[familyName];
// childless targets
if (typeof family === 'function') {
return family;
}
// find the first possibel target
var firstTarget = Object.keys(family).pop();
// shorthand
if (!target || typeof target === 'object') {
target = firstTarget;
}
// asking for a particular target
if (typeof target === 'string') {
// attempt to call the first one we find
if (typeof family[target] !== 'function') {
target = firstTarget;
}
// last chance
if (typeof family[target] === 'function') {
return family[target];
}
}
return false;
};
// exports

@@ -77,4 +123,10 @@

module.exports.info = function (lang) {
return targets[lang].info();
module.exports.info = function (family, target) {
var result = HTTPSnippet.prototype._matchTarget.call(null, family, target);
if (result) {
return result.info();
}
return false;
};

Sorry, the diff of this file is not supported yet

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