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-rc1 to 1.0.0-rc10

.nyc_output/fe38863b-89b5-4a68-92e9-b1c54cd9b741.json

4

CHANGELOG.json

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

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

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

@@ -5,3 +5,3 @@ # Change Log - @0xcert/utils

## 1.0.0-rc1
## 1.0.0-rc2
Thu, 22 Nov 2018 00:51:03 GMT

@@ -8,0 +8,0 @@

@@ -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": "npx nyc npx specron test "
"files": {
"packages/0xcert-utils/CHANGELOG.json": "6f0a4e70f48da4d04e3d0765e60615cf9d87d842",
"packages/0xcert-utils/CHANGELOG.md": "b063b728a89338c661d00f87296a14a26021a586",
"packages/0xcert-utils/README.md": "12c39c4428dd2fa3e5f419b7e3ae1ebacf1148f1",
"packages/0xcert-utils/nodemon.json": "82b893373db9861f1df4b55d8ea68a5d37b118de",
"packages/0xcert-utils/package.json": "61b3f6b9acc24b1bfac4b6eb5b2640dfda5f2424",
"packages/0xcert-utils/src/index.ts": "a40a59e4ffc9b7099602a46f9680dffb6e307f6e",
"packages/0xcert-utils/src/methods/fetch.ts": "351af6388c6af1b6df18ed040bc89d73a239212a",
"packages/0xcert-utils/src/methods/keccak.ts": "70bffccd2fa45a110d794c445d5ba8c152b8eb32",
"packages/0xcert-utils/src/methods/sha.ts": "adcda87f19b555678b0cc454eea97e2150726893",
"packages/0xcert-utils/src/methods/to-float.ts": "e44cc4338abf7d73ccabe640e3ead0abfe6dec44",
"packages/0xcert-utils/src/methods/to-integer.ts": "798f589b5f6f7da68c7241b0b2a677b63617c4b4",
"packages/0xcert-utils/src/methods/to-seconds.ts": "2f50bbde126ee11228ba0790499e9dcc863c8190",
"packages/0xcert-utils/src/methods/to-string.ts": "e71cc4af1e7669773aa0f67fd2d1b993c4bad2d5",
"packages/0xcert-utils/src/methods/to-tuple.ts": "7d9a6a53ce157d552203e20977a80958db65b06f",
"packages/0xcert-utils/src/tests/index.test.ts": "b4cc5d38f1981df96e417ab0730130990e79d34a",
"packages/0xcert-utils/src/tests/methods/fetch.test.ts": "f12804efea2aee890065cdff87852b73d7d5d8f5",
"packages/0xcert-utils/src/tests/methods/keccak.test.ts": "2cca7c33547ee81e344fc05b7e47e2ee552f5497",
"packages/0xcert-utils/src/tests/methods/sha.test.ts": "85d6c28a9928192ed45a2ecded6c4c26ab1bac15",
"packages/0xcert-utils/src/tests/methods/to-float.test.ts": "c8d4d54b5a7e37653243f09606d038b324fddaa2",
"packages/0xcert-utils/src/tests/methods/to-integer.test.ts": "d676adc99d44e370df36b9056e296c90483d858e",
"packages/0xcert-utils/src/tests/methods/to-seconds.test.ts": "3bb0b02e3ae3739a779f376b8f58e98f11644914",
"packages/0xcert-utils/src/tests/methods/to-string.test.ts": "d1f57e03baa4fb6b26edc9cb1d8bc800e5b046e6",
"packages/0xcert-utils/src/tests/methods/to-tuple.test.ts": "46278b2a9bd7918529fad7e0588bbd2058397199",
"packages/0xcert-utils/tsconfig.json": "4aeac3c20e45b7e477e82012eb7788f7dbb11bf3",
"packages/0xcert-utils/tslint.json": "c57b3f0cdb7aa74ab2ab02888380f613589cbe66",
"common/config/rush/npm-shrinkwrap.json": "b56bf5d9342bdd909289a88c77e60988dcde36a8"
},
"arguments": "npm run lint && npx nyc npx hayspec test "
}
{
"name": "@0xcert/utils",
"version": "1.0.0-rc1",
"version": "1.0.0-rc10",
"description": "General utility module with common helper functions.",

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

"lint": "npx tslint 'src/**/*.ts?(x)'",
"test": "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,15 +68,14 @@ },

"devDependencies": {
"@specron/cli": "^0.5.1",
"@specron/spec": "^0.5.1",
"node-fetch": "^2.3.0",
"@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"
},
"dependencies": {
"eth-lib": "0.1.27"
"eth-lib": "0.1.27",
"node-fetch": "^2.3.0"
}
}

@@ -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.
import * as Hash from 'eth-lib/src/hash';
/**
* Generates keccak256 hash.
*/
export function keccak256(input: any) {
return Hash.keccak256(input);
}
/**
* 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

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