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

@waves/assets-pairs-order

Package Overview
Dependencies
Maintainers
7
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@waves/assets-pairs-order - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

23

dist/index.js

@@ -1,7 +0,20 @@

(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b():'function'==typeof define&&define.amd?define(b):a.orderAssetsPairs=b()})(this,function(){'use strict';function a(a){if('number'!=typeof a||isNaN(a)||0>a||a>Number.MAX_SAFE_INTEGER||d(a)!==a)throw new Error('Value passed is not a non-negative safe integer.')}function b(a){if('string'!=typeof a)throw new Error('Value passed is not a string.')}function c(a){if(g[a]===void 0)throw new Error('Value passed is not a valid Base58 string.')}var d=Math.floor,e='123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ',f=e.length,g=e.split('').reduce(function(a,b,c){return a[b]=c,a},{}),h={encode:function(b){var c,g='';for(b=+b,a(b);b>=f;)c=b%f,g=e[c]+g,b=d(b/f);return e[b]+g},decode:function(a){return b(a),a.split('').reverse().reduce(function(a,b,d){return c(b),a+g[b]*Math.pow(f,d)},0)}},i=function(a,b){// 1 - arr1 bigger
// -1 - arr2 bigger
// 0 - equal
for(var c=0;c<a.length;c++){if(a[c]>b[c])return 1;if(a[c]<b[c])return-1}return 0},j=function(a){return Array.isArray(a)&&2===a.length&&a.every(function(a){return'string'==typeof a||null===a})},k=function(b){return Array.isArray(b)&&0===b.length},l=function(){function a(a,b){var c,d=[],e=!0,f=!1;try{for(var g,h=a[Symbol.iterator]();!(e=(g=h.next()).done)&&(d.push(g.value),!(b&&d.length===b));e=!0);}catch(a){f=!0,c=a}finally{try{!e&&h['return']&&h['return']()}finally{if(f)throw c}}return d}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),m=[{ticker:'USD',id:'Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck'},{ticker:'EUR',id:'Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU'},{ticker:'BTC',id:'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'},{ticker:'WAVES',id:null},{ticker:'BCH',id:'zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy'},{ticker:'ETH',id:'474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu'},{ticker:'LTC',id:'HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk'},{ticker:'ZEC',id:'BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa'}].map(function(a){return a.id}),n=function(a){return a.map(o)},o=function(a){var b=l(a,2),c=b[0],d=b[1],e=m.indexOf(c),f=m.indexOf(d),g=!!~e,j=!!~f;switch(!0){case g&&j:return e<f?[c,d]:[d,c];case g&&!j:return[c,d];case!g&&j:return[d,c];default:return 1===i(h.decode(c),h.decode(d))?[c,d]:[d,c];}};// Create a lookup table to fetch character index
(function(a,b){'object'==typeof exports&&'undefined'!=typeof module?module.exports=b(require('buffer')):'function'==typeof define&&define.amd?define(['buffer'],b):a.orderAssetsPairs=b(a.buffer)})(this,function(a){'use strict';a=a&&a.hasOwnProperty('default')?a['default']:a;var b=function(a,b){return b={exports:{}},a(b,b.exports),b.exports}(function(b,c){// alternative to using Object.keys for old browsers
function d(a,b){for(var c in a)b[c]=a[c]}function e(a,b,c){return f(a,b,c)}// Copy static methods from Buffer
/* eslint-disable node/no-deprecated-api */var f=a.Buffer;f.from&&f.alloc&&f.allocUnsafe&&f.allocUnsafeSlow?b.exports=a:(d(a,c),c.Buffer=e),d(f,e),e.from=function(a,b,c){if('number'==typeof a)throw new TypeError('Argument must not be a number');return f(a,b,c)},e.alloc=function(a,b,c){if('number'!=typeof a)throw new TypeError('Argument must be a number');var d=f(a);return void 0===b?d.fill(0):'string'==typeof c?d.fill(b,c):d.fill(b),d},e.allocUnsafe=function(a){if('number'!=typeof a)throw new TypeError('Argument must be a number');return f(a)},e.allocUnsafeSlow=function(b){if('number'!=typeof b)throw new TypeError('Argument must be a number');return a.SlowBuffer(b)}}),c=b.Buffer,d=b.Buffer,e=function(a){function b(a){if('string'!=typeof a)throw new TypeError('Expected String');if(0===a.length)return d.allocUnsafe(0);for(var b,c=[0],h=0;h<a.length;h++){if(b=e[a[h]],void 0===b)return;for(var i=0,j=b;i<c.length;++i)j+=c[i]*f,c[i]=255&j,j>>=8;for(;0<j;)c.push(255&j),j>>=8}// deal with leading zeros
for(var l=0;a[l]===g&&l<a.length-1;++l)c.push(0);return d.from(c.reverse())}// pre-compute lookup table
for(var c,e={},f=a.length,g=a.charAt(0),h=0;h<a.length;h++){if(c=a.charAt(h),void 0!==e[c])throw new TypeError(c+' is ambiguous');e[c]=h}return{encode:function(b){if(0===b.length)return'';for(var c=[0],d=0;d<b.length;++d){for(var e=0,h=b[d];e<c.length;++e)h+=c[e]<<8,c[e]=h%f,h=0|h/f;for(;0<h;)c.push(h%f),h=0|h/f}// deal with leading zeros
for(var i='',j=0;0===b[j]&&j<b.length-1;++j)i+=g;// convert digits to a string
for(var k=c.length-1;0<=k;--k)i+=a[c[k]];return i},decodeUnsafe:b,decode:function(a){var c=b(a);if(c)return c;throw new Error('Non-base'+f+' character')}}}('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'),f=function(a,b){// true - arr1 bigger
// false - arr2 bigger
// false - equal
return a.toString('hex')>b.toString('hex')},g=function(a){return Array.isArray(a)&&2===a.length&&a.every(function(a){return'string'==typeof a||a===null})},h=function(b){return Array.isArray(b)&&0===b.length},i=function(){function a(a,b){var c,d=[],e=!0,f=!1;try{for(var g,h=a[Symbol.iterator]();!(e=(g=h.next()).done)&&(d.push(g.value),!(b&&d.length===b));e=!0);}catch(a){f=!0,c=a}finally{try{!e&&h['return']&&h['return']()}finally{if(f)throw c}}return d}return function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return a(b,c);throw new TypeError('Invalid attempt to destructure non-iterable instance')}}(),j=[{ticker:'USD',id:'Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck'},{ticker:'EUR',id:'Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU'},{ticker:'BTC',id:'8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS'},{ticker:'WAVES',id:null},{ticker:'BCH',id:'zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy'},{ticker:'ETH',id:'474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu'},{ticker:'LTC',id:'HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk'},{ticker:'ZEC',id:'BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa'}].map(function(a){return a.id}),k=function a(){for(var b=arguments.length,c=Array(b),d=0;d<b;d++)c[d]=arguments[d];if(!a.predefinedList||!Array.isArray(a.predefinedList))throw new Error('Incorrect predefined assets list');switch(0===a.predefinedList.length&&console.warn('You have empty predefined assets list. This is probably not, what you desired. Check \'predefinedList\' property.'),!0){case 0===c.length||h(c[0]):return[];case 2===c.length&&g(c):return l([[c[0],c[1]]]);case Array.isArray(c[0])&&g(c[0][0]):return l.apply(void 0,c);case c.every(function(b){return g(b)}):return l([].concat(c));default:throw new Error('Incorrect arguments: '+JSON.stringify(c));}};// base-x encoding
// Forked from https://github.com/cryptocoinjs/bs58
// Originally written by Mike Hearn for BitcoinJ
// Copyright (c) 2011 Google Inc
// Ported to JavaScript by Stefan Thomas
// Merged Buffer refactorings from base58-native by Stephen Pair
// Copyright (c) 2013 BitPay Inc
// Entry point of package
// Check arguments and do the magic
return function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];switch(!0){case 0===b.length||k(b[0]):return[];case 2===b.length&&j(b):return n([[b[0],b[1]]]);case Array.isArray(b[0])&&j(b[0][0]):return n.apply(void 0,b);case b.every(function(b){return j(b)}):return n([].concat(b));default:throw new Error('Incorrect arguments: '+JSON.stringify(b));}}});
// By default predefinedList is mainNet data
k.predefinedList=j;var l=function(a){return a.map(m)},m=function(a){var b=i(a,2),c=b[0],d=b[1],g=k.predefinedList.indexOf(c),h=k.predefinedList.indexOf(d),j=!!~g,l=!!~h;switch(!0){case j&&l:return g<h?[c,d]:[d,c];case j&&!l:return[c,d];case!j&&l:return[d,c];default:return f(e.decode(c),e.decode(d))?[c,d]:[d,c];}};return k});
{
"name": "@waves/assets-pairs-order",
"version": "1.0.2",
"version": "2.0.0",
"main": "dist/index.js",

@@ -26,4 +26,4 @@ "license": "MIT",

"dependencies": {
"base58": "^1.0.1"
"bs58": "^4.0.1"
}
}
# Utility for ordering pair of assets in (amount_asset, price_asset)
## Accepts:
```javascript
orderPairs(string, string)
orderPairs([string, string])
orderPairs([string, string], [string, string], ...)
orderPairs([[string, string], [string, string], ...])
```
## Returns:
```javascript
[
[amount_asset1, price_asset1],
[amount_asset2, price_asset2],
...
]
```
## Example:

@@ -41,2 +58,17 @@ ```

*/
```
You can redefine `predefinedList` property:
(By default it's MAINNET_DATA)
```javascript
import orderPairs from '@waves/assets-pairs-order';
orderPairs.predefinedList = ['2', '1'];
orderPairs([['1','2']])
/* [
[
'2',
'1',
]
]
*/
```

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