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

@0xcert/utils

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@0xcert/utils - npm Package Compare versions

Comparing version 1.0.0-rc3 to 1.0.0-rc4

.nyc_output/37b5f5c3-89a6-4a3f-83ad-58e44acc7b36.json

4

CHANGELOG.json

@@ -5,4 +5,4 @@ {

{
"version": "1.0.0-rc3",
"tag": "@0xcert/utils_v1.0.0-rc3",
"version": "1.0.0-rc4",
"tag": "@0xcert/utils_v1.0.0-rc4",
"date": "Thu, 22 Nov 2018 00:51:03 GMT",

@@ -9,0 +9,0 @@ "comments": {}

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

export declare function toInteger(val: number): number;
export declare function toInteger(val: number | string | boolean): number;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function toInteger(val) {
return parseInt(`${val}`) || 0;
if (typeof val === 'number' && val > Number.MAX_SAFE_INTEGER) {
return 0;
}
else if (typeof val === 'boolean' && val === true) {
return 1;
}
else {
return parseInt(`${val}`) || 0;
}
}
exports.toInteger = toInteger;
//# sourceMappingURL=to-integer.js.map

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const utils = require("..");

@@ -14,4 +14,5 @@ const spec = new spec_1.Spec();

ctx.true(!!utils.toTuple);
ctx.true(!!utils.fetch);
});
exports.default = spec;
//# sourceMappingURL=index.test.js.map

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;

@@ -11,10 +11,10 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const fetch_1 = require("../../methods/fetch");
const spec = new spec_1.Spec();
spec.test('downloads a remote file', (ctx) => __awaiter(this, void 0, void 0, function* () {
const res = yield fetch_1.fetch('https://cdn.jsdelivr.net/gh/xpepermint/0xcert-contracts/asset-ledger.json').then((r) => r.json());
ctx.true(!!res.AssetLedger);
const res = yield fetch_1.fetch('https://docs.0xcert.org/xcert-mock.json').then((r) => r.json());
ctx.true(!!res.XcertMock);
}));
exports.default = spec;
//# sourceMappingURL=fetch.test.js.map

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;

@@ -11,3 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const keccak_1 = require("../../methods/keccak");

@@ -14,0 +14,0 @@ const spec = new spec_1.Spec();

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;

@@ -11,3 +11,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const sha_1 = require("../../methods/sha");

@@ -14,0 +14,0 @@ const spec = new spec_1.Spec();

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const __1 = require("../..");

@@ -5,0 +5,0 @@ const spec = new spec_1.Spec();

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const __1 = require("../..");

@@ -15,5 +15,8 @@ const spec = new spec_1.Spec();

ctx.is(__1.toInteger(null), 0);
ctx.is(__1.toInteger(true), 1);
ctx.is(__1.toInteger(false), 0);
ctx.is(__1.toInteger(undefined), 0);
ctx.is(__1.toInteger(Math.pow(2, 100)), 0);
});
exports.default = spec;
//# sourceMappingURL=to-integer.test.js.map

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const __1 = require("../..");

@@ -5,0 +5,0 @@ const spec = new spec_1.Spec();

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const __1 = require("../..");

@@ -5,0 +5,0 @@ const spec = new spec_1.Spec();

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
declare const spec: Spec<{}>;
export default spec;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const spec_1 = require("@specron/spec");
const spec_1 = require("@hayspec/spec");
const __1 = require("../..");

@@ -5,0 +5,0 @@ const spec = new spec_1.Spec();

{
"files": {},
"arguments": "npm run lint && npx nyc npx specron test "
"arguments": "npm run lint && npx nyc npx hayspec test "
}
{
"name": "@0xcert/utils",
"version": "1.0.0-rc3",
"version": "1.0.0-rc4",
"description": "General utility module with common helper functions.",

@@ -11,13 +11,10 @@ "main": "./dist/index.js",

"lint": "npx tslint 'src/**/*.ts?(x)'",
"test": "npm run lint && npx nyc npx specron test"
"test": "npm run lint && npx nyc npx hayspec test"
},
"specron": {
"test": {
"port": 8515,
"match": [
"./src/tests/**/*.test.ts"
]
},
"hayspec": {
"require": [
"ts-node/register"
],
"match": [
"./src/tests/**/*.test.ts"
]

@@ -71,10 +68,9 @@ },

"devDependencies": {
"@specron/cli": "^0.5.3",
"@specron/spec": "^0.5.3",
"@hayspec/cli": "^0.8.3",
"@hayspec/spec": "^0.8.3",
"@types/node": "10.12.24",
"nyc": "^13.1.0",
"solc": "0.5.1",
"ts-node": "^7.0.1",
"tslint": "^5.12.1",
"typescript": "^3.1.1",
"web3": "1.0.0-beta.36"
"typescript": "^3.1.1"
},

@@ -81,0 +77,0 @@ "dependencies": {

@@ -8,1 +8,5 @@ <img src="https://github.com/0xcert/framework/raw/master/assets/cover-sub.png" />

This module is one of the bricks of the [0xcert Framework](https://docs.0xcert.org). It's written with [TypeScript](https://www.typescriptlang.org) and it's actively maintained. The source code is available on [GitHub](https://github.com/0xcert/framework) where you can also find our [issue tracker](https://github.com/0xcert/framework/issues).
# Utilities
This small collection of functions are a convenience for common situations programming in TypeScript.
/**
* Converts float number to integer.
* Converts numeric values to integer.
*/
export function toInteger(val: number) {
return parseInt(`${val}`) || 0;
export function toInteger(val: number | string | boolean) {
if (typeof val === 'number' && val > Number.MAX_SAFE_INTEGER) {
return 0;
} else if (typeof val === 'boolean' && val === true) {
return 1;
} else {
return parseInt(`${val}`) || 0;
}
}

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import * as utils from '..';

@@ -14,4 +14,5 @@

ctx.true(!!utils.toTuple);
ctx.true(!!utils.fetch);
});
export default spec;

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { fetch } from '../../methods/fetch';

@@ -7,6 +7,6 @@

spec.test('downloads a remote file', async (ctx) => {
const res = await fetch('https://cdn.jsdelivr.net/gh/xpepermint/0xcert-contracts/asset-ledger.json').then((r) => r.json());
ctx.true(!!res.AssetLedger);
const res = await fetch('https://docs.0xcert.org/xcert-mock.json').then((r) => r.json());
ctx.true(!!res.XcertMock);
});
export default spec;

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { keccak256 } from '../../methods/keccak';

@@ -3,0 +3,0 @@

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { sha } from '../../methods/sha';

@@ -3,0 +3,0 @@

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { toFloat } from '../..';

@@ -3,0 +3,0 @@

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { toInteger } from '../..';

@@ -10,3 +10,3 @@

ctx.is(toInteger(0.1982), 0);
ctx.is(toInteger('10000.124' as any), 10000);
ctx.is(toInteger('10000.124'), 10000);
});

@@ -17,5 +17,8 @@

ctx.is(toInteger(null), 0);
ctx.is(toInteger(true), 1);
ctx.is(toInteger(false), 0);
ctx.is(toInteger(undefined), 0);
ctx.is(toInteger(2 ** 100), 0); // too big
});
export default spec;

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { toSeconds } from '../..';

@@ -3,0 +3,0 @@

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { toString } from '../..';

@@ -3,0 +3,0 @@

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

import { Spec } from '@specron/spec';
import { Spec } from '@hayspec/spec';
import { toTuple } from '../..';

@@ -3,0 +3,0 @@

@@ -239,11 +239,2 @@ {

"ban-ts-ignore": true,
"no-console": [
true,
"log",
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-debugger": true,

@@ -250,0 +241,0 @@ "no-eval": true,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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