New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

aylien_textapi

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aylien_textapi - npm Package Compare versions

Comparing version 0.1.3 to 0.2.0

coverage/coverage.json

28

lib/apirequest.js
/**
* Copyright 2014 Aylien, Inc. All Rights Reserved.
* Copyright 2015 Aylien, Inc. All Rights Reserved.
*

@@ -24,2 +24,4 @@ * Licensed under the Apache License, Version 2.0 (the "License");

var VERSION = "0.2.0";
function getMissingParams(params, required) {

@@ -62,10 +64,11 @@ if (typeof required === 'string') {

var endpoint = postParams.endpoint;
var protocol = https;
if (parameters.https === false) {
protocol = http;
}
delete(postParams.application_id);
delete(postParams.application_key);
delete(postParams.endpoint);
delete(postParams.https);
var postData = querystring.stringify(postParams);
var protocol = https;
if (parameters.https === false) {
protocol = http;
}

@@ -78,6 +81,7 @@ var request = protocol.request({

'Accept': 'application/json',
'User-Agent': 'Aylien Text API Node.js ' + VERSION,
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Length': Buffer.byteLength(postData, 'utf8'),
'X-AYLIEN-TextAPI-Application-ID': applicationId,
'X-AYLIEN-TextAPI-Application-Key': applicationKey
'X-AYLIEN-TextAPI-Application-Key': applicationKey,
},

@@ -90,8 +94,10 @@ }, function(response) {

response.on('end', function() {
var rateLimits = {};
['limit', 'remaining', 'reset'].forEach(function(r) {
rateLimits[r] = parseInt(response.headers['x-ratelimit-' + r] || '0', 10);
});
if (response.statusCode == 200) {
callback(null, JSON.parse(data));
} else if (response.statusCode == 403) {
callback(new Error(data), null);
callback(null, JSON.parse(data), rateLimits);
} else {
var errorString = "";
var errorString = data;
try {

@@ -101,3 +107,3 @@ var tmp = JSON.parse(data);

} catch(e) {}
callback(new Error("[" + response.statusCode + "] " + errorString));
callback(new Error(errorString), null, rateLimits);
}

@@ -104,0 +110,0 @@ });

/**
* Copyright 2014 Aylien, Inc. All Rights Reserved.
* Copyright 2015 Aylien, Inc. All Rights Reserved.
*

@@ -4,0 +4,0 @@ * Licensed under the Apache License, Version 2.0 (the "License");

{
"name": "aylien_textapi",
"description": "AYLIEN Text API Client Library for Node.js",
"version": "0.1.3",
"version": "0.2.0",
"author": "AYLIEN Inc.",

@@ -6,0 +6,0 @@ "contributors": [

/**
* Copyright 2014 Aylien, Inc. All Rights Reserved.
* Copyright 2015 Aylien, Inc. All Rights Reserved.
*

@@ -86,2 +86,3 @@ * Licensed under the Apache License, Version 2.0 (the "License");

* @param {string} params.url - URL
* @param {string} params.html - Raw HTML to extract from
* @param {boolean=} [params.best_image=false] - Whether to extract the

@@ -93,3 +94,4 @@ * best image of the article

params = util.extend({endpoint: 'extract'}, this.normalizeParams(params));
createAPIRequest(params, 'url', callback);
if (params.text && !params.html) { params.html = params.text; delete(params.text); }
createAPIRequest(params, [['url', 'html']], callback);
};

@@ -138,2 +140,24 @@

/**
* textapi.unsupervisedClassify
*
* @desc Picks the most semantically relevant class label or tag for a
* piece of text.
*
* @memberof! aylien_textapi(v1)
* @instance
*
* @param {object} params - Parameters for request
* @param {string} params.text - Text
* @param {string} params.url - URL
* @param {array} params.class - List of classes to classify into
* @param {integer=} [params.number_of_concepts=250] - Number of
* concepts to use to measure the semantic similarity of two words.
* @param {callback} callback - The callback that handles the response
*/
this.unsupervisedClassify = function(params, callback) {
params = util.extend({endpoint: 'classify/unsupervised'}, this.normalizeParams(params));
createAPIRequest(params, [['text', 'url'], 'class'], callback);
};
/**
* textapi.concepts

@@ -245,2 +269,19 @@ *

};
/**
* textapi.microformats
*
* @desc Extracts microformats from a URL
*
* @memberof! aylien_textapi(v1)
* @instance
*
* @param {object} params - Parameters for request
* @param {string} params.url - URL to extract microformats from
* @param {callback} callback - The callback that handles the response
*/
this.microformats = function(params, callback) {
params = util.extend({endpoint: 'microformats'}, this.normalizeParams(params));
createAPIRequest(params, 'url', callback);
};
}

@@ -247,0 +288,0 @@

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