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

resources-tsk

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resources-tsk - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

34

CHANGELOG.md
# Changelog
## [1.0.0] — 2020-08-09
- Release first version
## [1.0.1] — 2020-08-09
### Removed
- Unnecessary files
## [1.0.3] — 2020-08-09
### Added
- Types and root file.
## [1.0.4] — 2020-08-10
### Updated
- Documentation.
## [1.0.5] — 2020-08-11
### Updated
- Documentation.
## [1.0.6] — 2020-08-13
### Added
- Runkit example file.
## [1.1.0] — 2020-08-16
### Updated
- Pure function concept was supported.
## [1.1.2] — 2020-08-17
### Updated
- Change strategy to manage runkit example file.
## [1.1.3] — 2020-08-23
### Updated
- Package json keywords.
## [1.1.4] — 2020-08-29
### Added
- Function for initialize default language.
## [1.1.5] — 2020-08-29
### Updated
- NPM package dependencies.
## [1.1.6] — 2020-09-14
### Updated
- Language is validated in the init function.
### Added
- Function to update locals at any time.
## [1.1.8] — 2020-12-10
### Updated
- NPM package dependencies was updated.
## [1.1.9] — 2021-01-10
### Updated
- Setting for tsconfig was changed, lib to ES2020 and target to es6.
- Packages was updated

2

demo/runkitExample.js

@@ -1,2 +0,2 @@

var res_tsk = require("resources-tsk");
const res_tsk = require("resources-tsk");

@@ -3,0 +3,0 @@ // local or remote resource

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Resources = void 0;
var Resources = /** @class */ (function () {
function Resources(locals, localKeys, defaultLanguage) {
var _this = this;
class Resources {
constructor(locals, localKeys, defaultLanguage) {
this.defaultLanguage = null;

@@ -16,9 +15,9 @@ this.globalLanguage = null;

this.defaultLanguage = defaultLanguage;
var keysToCheck = Object.keys(this.resourceKeys);
var langToCheck = Object.keys(locals);
var resourcesNotFound = [];
keysToCheck.forEach(function (key) {
langToCheck.forEach(function (lang) {
if (!_this.locals[lang][key]) {
resourcesNotFound.push(lang + ": " + key);
const keysToCheck = Object.keys(this.resourceKeys);
const langToCheck = Object.keys(locals);
const resourcesNotFound = [];
keysToCheck.forEach((key) => {
langToCheck.forEach((lang) => {
if (!this.locals[lang][key]) {
resourcesNotFound.push(`${lang}: ${key}`);
}

@@ -28,7 +27,7 @@ });

if (resourcesNotFound.length > 0) {
throw new Error("The messages for " + resourcesNotFound.join(", ") + " was not found in local resources.");
throw new Error(`The messages for ${resourcesNotFound.join(", ")} was not found in local resources.`);
}
}
/* Setting the default language */
Resources.prototype.SetDefaultLanguage = function (defaultLanguage) {
SetDefaultLanguage(defaultLanguage) {
if (!this.locals[defaultLanguage]) {

@@ -38,5 +37,5 @@ throw new Error("Default language not found in local resources.");

this.defaultLanguage = defaultLanguage;
};
}
/* Set the current working language */
Resources.prototype.Init = function (language) {
Init(language) {
if (!language) {

@@ -46,15 +45,14 @@ return;

if (!this.locals[language]) {
console.log("Accept-Language \"" + language + "\" not found in locals resource.");
console.log(`Accept-Language "${language}" not found in locals resource.`);
return;
}
this.globalLanguage = language;
};
}
/* Update the current locals */
Resources.prototype.UpdateLocals = function (locals) {
UpdateLocals(locals) {
if (locals) {
this.locals = locals;
}
};
Resources.prototype.Get = function (resourceName, language) {
if (language === void 0) { language = null; }
}
Get(resourceName, language = null) {
if (language && this.locals[language] && this.locals[language][resourceName]) {

@@ -71,7 +69,6 @@ return this.locals[language][resourceName];

}
throw new Error("Resource " + resourceName + " not found in any local resource.");
};
Resources.prototype.GetWithParams = function (resourceName, params, language) {
if (language === void 0) { language = null; }
var resource = null;
throw new Error(`Resource ${resourceName} not found in any local resource.`);
}
GetWithParams(resourceName, params, language = null) {
let resource = null;
if (language && this.locals[language] && this.locals[language][resourceName]) {

@@ -89,16 +86,15 @@ resource = this.locals[language][resourceName];

if (!resource) {
throw new Error("Resource " + resourceName + " not found in any local resource.");
throw new Error(`Resource ${resourceName} not found in any local resource.`);
}
var keys = Object.keys(params);
keys.forEach(function (key) {
var pattern = "({{)" + key + "(}})";
var regex = RegExp(pattern);
const keys = Object.keys(params);
keys.forEach((key) => {
const pattern = `({{)${key}(}})`;
const regex = RegExp(pattern);
while (regex.test(resource)) {
resource = resource.replace("{{" + key + "}}", params[key]);
resource = resource.replace(`{{${key}}}`, params[key]);
}
});
return resource;
};
return Resources;
}());
}
}
exports.Resources = Resources;
{
"name": "resources-tsk",
"version": "1.1.8",
"version": "1.1.9",
"description": "resource tool for use with or without NodeTskeleton template project",

@@ -13,7 +13,7 @@ "repository": {

"tskeleton",
"flow",
"control",
"work flow",
"flow control",
"tool"
],
"author": "harvic3@ingenieros.com",
"author": "Vickodev<harvic3@ingenieros.com>",
"license": "MIT",

@@ -32,6 +32,7 @@ "homepage": "https://github.com/harvic3/nodetskeleton-tools/blob/master/src/resources-tsk/README.md",

"build": "rm -rf lib/* && tsc --sourceMap false",
"build-map": "rm -rf lib/* && tsc",
"upload": "npm run build && npm publish"
},
"devDependencies": {
"@types/node": "^14.14.12",
"@types/node": "^14.14.20",
"typescript": "^3.9.7"

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