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

@barchart/common-js

Package Overview
Dependencies
Maintainers
1
Versions
457
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@barchart/common-js - npm Package Compare versions

Comparing version 3.0.7 to 3.0.8

collections/LinkedList.js

6

collections/Tree.js

@@ -10,3 +10,3 @@ module.exports = (() => {

* @public
* @param {object} value - The value of the node.
* @param {*} value - The value of the node.
* @param {Tree} parent - The parent node. If not supplied, this will be the root node.

@@ -46,3 +46,3 @@ */

* @public
* @returns {object}
* @returns {*}
*/

@@ -78,3 +78,3 @@ getValue() {

* @public
* @param {object} value - The value of the child.
* @param {*} value - The value of the child.
* @returns {Tree}

@@ -81,0 +81,0 @@ */

@@ -5,3 +5,4 @@ const assert = require('./assert'),

const Decimal = require('./Decimal');
const Currency = require('./Currency'),
Decimal = require('./Decimal');

@@ -11,6 +12,16 @@ module.exports = (() => {

/**
* A component that represents an exchange rate, composed of a {@link Decimal}
* value and two currencies -- a quote (i.e. the numerator) currency and a
* base (i.e. denominator) currency.
*
* @public
* @param {Number|String|Decimal} value - The rate
* @param {Currency} numerator - The quote currency
* @param {Currency} denominator - The base currency
*/
class Rate {
constructor(value, denominator, numerator) {
assert.argumentIsRequired(numerator, 'numerator', String);
assert.argumentIsRequired(denominator, 'denominator', String);
constructor(value, numerator, denominator) {
assert.argumentIsRequired(numerator, 'numerator', Currency, 'Currency');
assert.argumentIsRequired(denominator, 'denominator', Currency, 'Currency');

@@ -26,2 +37,8 @@ if (numerator === denominator) {

/**
* The rate.
*
* @public
* @returns {Decimal}
*/
get decimal() {

@@ -31,2 +48,9 @@ return this._decimal;

/**
* The numerator (i.e. quote) currency. In other words,
* this is EUR of the EURUSD pair.
*
* @public
* @returns {Currency}
*/
get numerator() {

@@ -36,2 +60,9 @@ return this._numerator;

/**
* The quote (i.e. numerator) currency. In other words,
* this is EUR of the EURUSD pair.
*
* @public
* @returns {Currency}
*/
get quote() {

@@ -41,2 +72,9 @@ return this._numerator;

/**
* The denominator (i.e. base) currency. In other words,
* this is USD of the EURUSD pair.
*
* @public
* @returns {Currency}
*/
get denominator() {

@@ -46,2 +84,9 @@ return this._denominator;

/**
* The base (i.e. denominator) currency. In other words,
* this is USD of the EURUSD pair.
*
* @public
* @returns {Currency}
*/
get base() {

@@ -51,2 +96,9 @@ return this._denominator;

/**
* Formats the currency pair as a string (e.g. "EURUSD" or "^EURUSD").
*
* @public
* @param {Boolean=} useCarat - If true, a carat is used as a prefix to the resulting string.
* @returns {string}
*/
formatPair(useCarat) {

@@ -58,2 +110,10 @@ assert.argumentIsOptional(useCarat, 'useCarat', Boolean);

/**
* Creates a {@link Rate} instance, when given a value
*
* @public
* @param {Number|String|Decimal} value - The rate.
* @param {Currency} pair - A string that can be parsed as a currency pair.
* @returns {Rate}
*/
static fromPair(value, pair) {

@@ -60,0 +120,0 @@ assert.argumentIsRequired(pair, 'pair', String);

@@ -68,7 +68,7 @@ const assert = require('./../../lang/assert');

* @public
* @param {Function} reviver
* @param {Function} reviverFactory - A function that returns a JSON.parse reviver function
* @returns {RestParser}
*/
static getJsonParser(reviver) {
return new DelegatedRestParser(x => JSON.parse(x, reviver));
static getJsonParser(reviverFactory) {
return new DelegatedRestParser(x => JSON.parse(x, reviverFactory()));
}

@@ -75,0 +75,0 @@

{
"name": "@barchart/common-js",
"version": "3.0.7",
"version": "3.0.8",
"description": "Library of common javascript utilities",

@@ -5,0 +5,0 @@ "author": {

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

const assert = require('./../../../lang/assert');
const assert = require('./../../../lang/assert'),
is = require('./../../../lang/is');

@@ -40,10 +41,14 @@ const Component = require('./../Component'),

* @param {DataType} dataType - The type of the new field.
* @param {Boolean} optional - The
* @returns {SchemaBuilder}
*/
withField(name, dataType) {
withField(name, dataType, optional) {
assert.argumentIsRequired(name, 'name', String);
assert.argumentIsRequired(dataType, 'dataType', DataType, 'DataType');
assert.argumentIsOptional(optional, 'optional', Boolean);
const fields = this._schema.fields.concat([ new Field(name, dataType) ]);
const optionalToUse = is.boolean(optional) && optional;
const fields = this._schema.fields.concat([ new Field(name, dataType, optionalToUse) ]);
this._schema = new Schema(this._schema.name, fields, this._schema.components, this._schema.strict);

@@ -50,0 +55,0 @@

@@ -12,7 +12,9 @@ const DataType = require('./DataType');

* @param {DataType} dataType
* @param {Boolean} optional
*/
class Field {
constructor(name, dataType) {
constructor(name, dataType, optional) {
this._name = name;
this._dataType = dataType;
this._optional = optional || false;
}

@@ -40,2 +42,12 @@

/**
* Indicates if the field can be omitted without violating the schema.
*
* @public
* @returns {Boolean}
*/
get optional() {
return this._optional;
}
toString() {

@@ -42,0 +54,0 @@ return `[Field (name=${this._name})]`;

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

const array = require('./../../lang/array'),
assert = require('./../../lang/assert'),
const assert = require('./../../lang/assert'),
is = require('./../../lang/is'),

@@ -100,3 +99,3 @@ functions = require('./../../lang/functions');

if (!reviverItem.reset && key !== reviverItem.name) {
if (!(key === reviverItem.name || reviverItem.reset || (key === '' && reviverIndex === 0))) {
throw new Error(`Schema parsing is using strict mode, unexpected key found [ ${key} ]`);

@@ -111,2 +110,13 @@ }

/**
* Returns a function that will genenrate a *new* reviver function
* (see {@link Schema#getReviver}.
*
* @public
* @returns {Function}
*/
getReviverFactory() {
return () => this.getReviver();
}
toString() {

@@ -121,3 +131,3 @@ return `[Schema (name=${this._name})]`;

this._reviver = reviver || functions.getTautology();
this._reset = true;
this._reset = is.boolean(reset) && reset;
}

@@ -139,3 +149,3 @@

function getReviverItems(fields, components) {
const root = new Tree(new ReviverItem(''));
const root = new Tree(new ReviverItem(null, null, true));

@@ -142,0 +152,0 @@ // 2017/08/26, BRI. The Field and Component types could inherit a common

@@ -10,5 +10,9 @@ var RestParser = require('./../../../../network/rest/RestParser');

beforeEach(function () {
parser = RestParser.getJsonParser(spy = jasmine.createSpy('spy').and.callFake(function (k, v) {
return k === 'fizz' ? 3 : v;
}));
function parserFactory() {
return spy = jasmine.createSpy('spy').and.callFake(function (k, v) {
return k === 'fizz' ? 3 : v;
});
}
parser = RestParser.getJsonParser(parserFactory);
});

@@ -45,5 +49,9 @@

beforeEach(function () {
parser = RestParser.getJsonParser(spy = jasmine.createSpy('spy').and.callFake(function (k, v) {
return k === 'fizz' ? 3 : v;
}));
function parserFactory() {
return spy = jasmine.createSpy('spy').and.callFake(function (k, v) {
return k === 'fizz' ? 3 : v;
});
}
parser = RestParser.getJsonParser(parserFactory);
});

@@ -50,0 +58,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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