Socket
Socket
Sign inDemoInstall

pragmatismo-io-framework

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pragmatismo-io-framework - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

4

dist/AzureText.js

@@ -53,4 +53,4 @@ /*****************************************************************************\

let https = require("https");
let host = "api.cognitive.microsoft.com";
let path = "/bing/v7.0/spellcheck";
let host = "api.bing.microsoft.com";
let path = "/v7.0/spellcheck";
let mkt = "pt-PT";

@@ -57,0 +57,0 @@ let mode = "spell";

{
"name": "pragmatismo-io-framework",
"version": "1.1.0",
"version": "1.1.1",
"description": "Anything reusable turned into typed classes.",

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

@@ -46,69 +46,59 @@ /*****************************************************************************\

let https = require("https");
let host = "api.cognitive.microsoft.com";
let path = "/bing/v7.0/spellcheck";
let host = "api.bing.microsoft.com";
let path = "/v7.0/spellcheck";
let mkt = "pt-PT";
let mode = "spell";
let query_string = "?mkt=" + mkt + "&mode=" + mode;
let request_params = {
method: "POST",
hostname: host,
path: path + query_string,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": text.length + 5,
"Ocp-Apim-Subscription-Key": key
}
method: "POST",
hostname: host,
path: path + query_string,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Content-Length": text.length + 5,
"Ocp-Apim-Subscription-Key": key
}
};
let getCorrectedText = (sourceText: string, response: any) => {
let getWordIndexByWordOffsetInText = function(text, wordOffsetInText) {
let getCorrectedText = (sourceText, response) => {
let getWordIndexByWordOffsetInText = function (text, wordOffsetInText) {
let index = 0;
let currentWordIndex = 0;
text = text.split(" ");
text.forEach(element => {
if (index >= wordOffsetInText) {
return false;
}
index += element.length + 1;
currentWordIndex++;
});
return currentWordIndex;
};
let replaceWordAtIndex = function (text, index, replacement) {
text = text.split(" ");
text[index] = replacement;
text = text.join(" ");
return text;
};
let index = 0;
let currentWordIndex = 0;
text = text.split(" ");
text.forEach(element => {
if (index >= wordOffsetInText) {
return false;
}
index += element.length + 1;
currentWordIndex++;
if (response.flaggedTokens) {
response.flaggedTokens.forEach(element => {
index = getWordIndexByWordOffsetInText(sourceText, element.offset);
sourceText = replaceWordAtIndex(sourceText, index, element.suggestions[0].suggestion);
index++;
});
}
return sourceText;
};
let response_handler = response => {
let body = "";
response.on("data", d => {
body += d;
});
return currentWordIndex;
};
let replaceWordAtIndex = function(text, index, replacement) {
text = text.split(" ");
text[index] = replacement;
text = text.join(" ");
return text;
};
let index = 0;
if (response.flaggedTokens) {
response.flaggedTokens.forEach(element => {
index = getWordIndexByWordOffsetInText(sourceText, element.offset);
sourceText = replaceWordAtIndex(
sourceText,
index,
element.suggestions[0].suggestion
);
index++;
response.on("end", () => {
resolve(getCorrectedText(text, JSON.parse(body)));
});
}
return sourceText;
response.on("error", e => {
reject(`Error calling Spelling API: ${e}`);
});
};
let response_handler = response => {
let body = "";
response.on("data", d => {
body += d;
});
response.on("end", () => {
resolve(getCorrectedText(text, JSON.parse(body)));
});
response.on("error", e => {
reject(`Error calling Spelling API: ${e}`);
});
};
let req = https.request(request_params, response_handler);

@@ -115,0 +105,0 @@ req.write("text=" + text);

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