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

softmax-fn

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

softmax-fn - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

dist/index.min.js

149

dist/index.js

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

"use strict";(function(e,n,t){function r(e){return this[e]}function u(){return"undefined"!=typeof module&&"undefined"!=typeof module.exports}function i(){return"function"==typeof define&&define.amd}var f=this;if(u()){var o=n.map(require);exports=module.exports=f[e]=t.apply(null,o)}else if(i())define(e,n,function(){var n=f[e]=t.call(null,arguments);return n});else{var a=n.map(r,f);f[e]=t.apply(null,a)}}).call(void 0,"softmax",[],function(){function e(e){if(e.map(r),1===e.length)return[1];var u=e.map(Math.exp),i=u.reduce(n,0);return u.map(t,i)}function n(e,n){return e+n}function t(e){return e/this}function r(e){if("number"!=typeof e)throw u(e);switch(e){case 1/0:case-(1/0):case Number.MAX_VALUE:case-Number.MAX_VALUE:throw u(e)}}function u(e){return"Invalid argument specified: "+JSON.stringify(e)}return e});
/**
* Register a module for CommonJS, AMD, and the global namespace.
*
* @param {string} id The identity of the module
* @param {string[]} dependencyNames List of dependency names
* @param {function} instantiate Factory method to get the module
* @return {undefined}
*/
(function registerModule(id, dependencyNames, instantiate) {
'use strict';
var that = this;
if (isCommonJs()) {
var dependencies = dependencyNames.map(require);
exports = module.exports = that[id] = instantiate.apply(null, dependencies);
} else if (isAmd()) {
define(id, dependencyNames, function factory() {
var result = that[id] = instantiate.call(null, arguments);
return result;
});
} else {
var _dependencies = dependencyNames.map(getThis, that);
that[id] = instantiate.apply(null, _dependencies);
}
/**
* Get the value of an objects key
*
** @this {object} The source
* @param {string} key The key
* @return {*} The objects key value
*/
function getThis(key) {
return this[key];
}
/**
* Determines if the environment appears to be CommonJS
*
* @return {boolean} True if environment is CommonJS, otherwise false
*/
function isCommonJs() {
return typeof module !== 'undefined' && typeof module.exports !== 'undefined';
}
/**
* Determines if the environment supports Asynchronous module definition (AMD)
*
* @return {boolean} True if environment supports AMD, otherwise false
*/
function isAmd() {
return typeof define === 'function' && define.amd;
}
}).call(this || {}, 'softmax', [], function instantiate() {
'use strict';
return softmax;
/**
* Softmax
* @param {number[]} values A list of numbers ranging from -10 to 10
* @return {number[]} The normalized list of entries between 0 and 1
* where the sum is 1.
*/
function softmax(values) {
values.map(checkValue);
if (values.length === 1) {
return [1];
}
var exponents = values.map(Math.exp),
total = exponents.reduce(sum, 0);
return exponents.map(divide, total);
}
/**
* Sum
* @param {number} augend The number to whcih an addend is added.
* @param {number} addend A number that is added to another.
* @returns {number} The sum
*/
function sum(augend, addend) {
return augend + addend;
}
/**
* Divide
** @this {number} The divisor
* @param {number} dividend The number to be divided
* @returns {number} The quotient
*/
function divide(dividend) {
return dividend / this;
}
/**
* Checks the value to determine if it is valid
* @param {*} value The value
* @throws {invalidArgumentMessage} The value must be a number in-range
* @returns {undefined}
*/
function checkValue(value) {
if (typeof value !== 'number') {
throw invalidArgumentMessage(value);
}
switch (value) {
case Infinity:
case -Infinity:
case Number.MAX_VALUE:
case -Number.MAX_VALUE:
throw invalidArgumentMessage(value);
default:
}
}
/**
* An invalid argument message
* @param {*} value The value of the argument
* @returns {string} The message indicating that the value is invalid.
*/
function invalidArgumentMessage(value) {
return 'Invalid argument specified: ' + JSON.stringify(value);
}
});
//# sourceMappingURL=index.js.map

2

lib/index.js

@@ -74,3 +74,3 @@ (

}.call(this, 'softmax', [], function instantiate() {
}.call(this || {}, 'softmax', [], function instantiate() {

@@ -77,0 +77,0 @@ 'use strict';

{
"name": "softmax-fn",
"version": "1.0.2",
"version": "1.0.3",
"description": "Softmax Function",

@@ -40,13 +40,14 @@ "main": "dist/index.js",

"devDependencies": {
"babel-preset-es2015": "^6.9.0",
"babel-preset-es2015-script": "^1.0.0",
"coffee-script": "^1.10.0",
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-concat": "^2.6.0",
"gulp-istanbul": "^0.10.4",
"gulp-jasmine": "^2.3.0",
"gulp-rename": "^1.2.2",
"gulp-sourcemaps": "^2.0.0-alpha",
"gulp-uglify": "^1.5.3",
"istanbul": "^0.4.3",
"jasmine": "^2.4.1",
"gulp": "^3.9.1",
"gulp-concat": "^2.6.0",
"gulp-sourcemaps": "^2.0.0-alpha",
"gulp-uglify": "^1.5.3"
"jasmine": "^2.4.1"
},

@@ -53,0 +54,0 @@ "dependencies": {},

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