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

repository-provider

Package Overview
Dependencies
Maintainers
1
Versions
662
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

repository-provider - npm Package Compare versions

Comparing version 8.0.1 to 8.1.0

185

dist/provider.js

@@ -994,6 +994,180 @@ 'use strict';

/**
* @callback Logger
* @property {Object} entry
*/
/**
* @typedef {Object} Loglevel
* @property {string} name
* @property {number} priority
*/
/**
* default log levels
* - trace
* - debug
* - info
* - notice
* - warn
* - error
* - crit
* - alert
*/
const defaultLogLevels = declareLevels([
'trace',
'debug',
'info',
'notice',
'warn',
'error',
'crit',
'alert'
]);
/**
* Generate the loglevel objects out of a list of log level names.
* @param {string[]} list A list of log level names. The last name in the list will become the one with the highest priority.
* @return {Object} levels object a hash with all the loglevels. Stored by there name.
*/
function declareLevels(list) {
const levels = {};
let priority = list.length;
list.forEach(name => {
levels[name] = {
name,
priority
};
priority -= 1;
});
return levels;
}
/**
* <!-- skip-example -->
* Adds logging methods to an existing object.
* For each loglevel a method with the name of the log level will be created.
* @param {Object} object target where to assign properties to
* @param {Object} logLevels Hash with all the available loglevels. Stored by there name
* @param {Logger} theFunction to be added under the loglevel name.
* This function will only be called if the current loglevel is greater equal
* the log level of the called logging function.
* By default a method log(level,message) will be used
* @return {undefined}
* @example
* defineLoggerMethods( obj)
* obj.info('info entry'); // will redirect to theFunction if obj.loglevel is at least info
* obj.error('error entry'); // will redirect to theFunction if obj.loglevel is at least error
*/
function defineLoggerMethods(
object,
logLevels = defaultLogLevels,
theFunction = undefined
) {
const properties = {};
Object.keys(logLevels).forEach(level => {
const myLevel = logLevels[level].priority;
const levelName = level;
properties[levelName] = {
value:
theFunction === undefined
? function(providerFunction) {
if (this.logLevelPriority >= myLevel) {
this.log(
levelName,
typeof providerFunction === 'function'
? providerFunction(levelName)
: providerFunction
);
}
}
: function(providerFunction) {
if (this.logLevelPriority >= myLevel) {
theFunction.call(
this,
levelName,
typeof providerFunction === 'function'
? providerFunction(levelName)
: providerFunction
);
}
},
enumerable: true
};
});
Object.defineProperties(object, properties);
}
/**
* symbol holding the actual logLevel inside of the target object
*/
const LOGLEVEL = Symbol('loglevel');
/**
* <!-- skip-example -->
* @class
* @classdesc This function is a mixin for ES2015 classes.
* @param {class} superclass class to be extendet
* @param {Object} logLevels Object with all the available loglevels. Stored by their name
* @param {string} defaultLogLevel the default value for the logLevel property
* @return {class} newly created class ready to be further extendet/used
* @example
* import { LogLevelMixin } = from 'loglevel-mixin';
* class BaseClass {
* log(level, message) { console.log(`${level} ${message}`); }
* }
* class LoggingEnabledClass extends LogLevelMixin(BaseClass) {
* }
* @mixin
*/
function LogLevelMixin(
superclass,
logLevels = defaultLogLevels,
defaultLogLevel = defaultLogLevels.info
) {
const newClass = class extends superclass {
/**
* set the log level to the default
*/
constructor(...args) {
super(...args);
this[LOGLEVEL] = defaultLogLevel;
}
/**
* @return {string} name of the current log level
*/
get logLevel() {
return this[LOGLEVEL].name;
}
/**
* Set the logging level.
* if an unknown logLevel is given the default logLevel will be used.
* @param {string} level
*/
set logLevel(level) {
this[LOGLEVEL] = logLevels[level] || defaultLogLevel;
}
/**
* @return {number} priority of the current log level
*/
get logLevelPriority() {
return this[LOGLEVEL].priority;
}
};
defineLoggerMethods(newClass.prototype, logLevels);
return newClass;
}
/**
* Collection of repositories
* @property {Map<string,Repository>} repositories
*/
const Owner = OneTimeInititalizerMixin(
const Owner = LogLevelMixin(OneTimeInititalizerMixin(
class Owner {

@@ -1004,3 +1178,8 @@ /**

static get defaultOptions() {
return {};
return {
/**
* default logger
*/
logger: (...arg) => console.log(...args)
};
}

@@ -1119,3 +1298,3 @@

}
);
));

@@ -1122,0 +1301,0 @@ /**

3

package.json
{
"name": "repository-provider",
"version": "8.0.1",
"version": "8.1.0",
"publishConfig": {

@@ -32,2 +32,3 @@ "access": "public"

"dependencies": {
"loglevel-mixin": "^2.0.5",
"to-readable-stream": "^1.0.0"

@@ -34,0 +35,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