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 2.0.0-alpha1 to 2.0.0-alpha10

.nyc_output/7e2d876f-2f48-481b-8233-e76cb628a4e7.json

4

CHANGELOG.json

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

{
"version": "2.0.0-alpha1",
"tag": "@0xcert/utils_v2.0.0-alpha1",
"version": "2.0.0-alpha10",
"tag": "@0xcert/utils_v2.0.0-alpha10",
"date": "Wed, 19 Jun 2019 10:31:05 GMT",

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

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

## 2.0.0-alpha1
## 2.0.0-alpha10
Wed, 19 Jun 2019 10:31:05 GMT

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

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

export declare function fetch(path: any, options?: any): Promise<any>;
export declare function fetchJson(path: any, options?: any): Promise<any>;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -11,13 +12,21 @@ });

Object.defineProperty(exports, "__esModule", { value: true });
function fetch(path, options) {
function fetchJson(path, options) {
return __awaiter(this, void 0, void 0, function* () {
if (typeof window !== 'undefined') {
return window.fetch(path, options);
return window.fetch(path, options).then((r) => r.json());
}
else if (path.lastIndexOf('http', 0) !== 0) {
try {
return require('fs').promises.readFile(path, 'utf8').then((d) => JSON.parse(d));
}
catch (e) {
return null;
}
}
else {
return require('node-fetch')(path, options);
return require('node-fetch')(path, options).then((r) => r.json());
}
});
}
exports.fetch = fetch;
exports.fetchJson = fetchJson;
//# sourceMappingURL=fetch.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

@@ -14,5 +14,5 @@ "use strict";

ctx.true(!!utils.toTuple);
ctx.true(!!utils.fetch);
ctx.true(!!utils.fetchJson);
});
exports.default = spec;
//# sourceMappingURL=index.test.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -12,9 +13,14 @@ });

const spec_1 = require("@hayspec/spec");
const path = require("path");
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://docs.0xcert.org/xcert-mock.json').then((r) => r.json());
spec.test('downloads a remote file', (ctx) => __awaiter(void 0, void 0, void 0, function* () {
const res = yield fetch_1.fetchJson('https://docs.0xcert.org/xcert-mock.json');
ctx.true(!!res.XcertMock);
}));
spec.test('reads a local file', (ctx) => __awaiter(void 0, void 0, void 0, function* () {
const res = yield fetch_1.fetchJson(path.join(__dirname, '..', 'mocks', 'xcert-mock.json'));
ctx.true(!!res.XcertMock);
}));
exports.default = spec;
//# sourceMappingURL=fetch.test.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -14,3 +15,3 @@ });

const spec = new spec_1.Spec();
spec.test('converts string into keccak256 hash', (ctx) => __awaiter(this, void 0, void 0, function* () {
spec.test('converts string into keccak256 hash', (ctx) => __awaiter(void 0, void 0, void 0, function* () {
ctx.is(keccak_1.keccak256('foo#'), '0xe7bb87eda991af44cdb673a7d5f2bfeb854dd089e421b3934d022fc5c29259a0');

@@ -17,0 +18,0 @@ ctx.is(keccak_1.keccak256('bar!'), '0x179eb773d34690d312adc3f96661402e2de2009e39dbf4b8dee22b3adc842752');

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -14,3 +15,3 @@ });

const spec = new spec_1.Spec();
spec.test('converts string into SHA256 hash', (ctx) => __awaiter(this, void 0, void 0, function* () {
spec.test('converts string into SHA256 hash', (ctx) => __awaiter(void 0, void 0, void 0, function* () {
ctx.is(yield sha_1.sha(256, 'foo#'), '18845243706c9f9a00b514348b58edd82fe708a68393ccbb3f70e1599577a148');

@@ -17,0 +18,0 @@ ctx.is(yield sha_1.sha(256, 'bar!'), 'e687b749f2cd93615923a2f705faace4033f35d57ccfca652cdc39616a94a3c2');

{
"name": "@0xcert/utils",
"version": "2.0.0-alpha1",
"version": "2.0.0-alpha10",
"description": "General utility module with common helper functions.",

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

"devDependencies": {
"@hayspec/cli": "^0.8.3",
"@hayspec/spec": "^0.8.3",
"@types/node": "^10.12.24",
"nyc": "^13.1.0",
"ts-node": "^7.0.1",
"tslint": "^5.12.1",
"typescript": "^3.1.1"
"@hayspec/cli": "0.9.0",
"@hayspec/spec": "0.9.0",
"@types/node": "12.7.8",
"nyc": "14.1.1",
"ts-node": "8.4.1",
"tslint": "5.20.0",
"typescript": "3.6.3"
},
"dependencies": {
"eth-lib": "0.1.27",
"node-fetch": "^2.3.0"
"eth-lib": "0.2.8",
"node-fetch": "2.6.0"
}
}
/**
* Universal fetch method reads remote or local file.
* Universal fetch method reads remote or local JSON file.
* @param path URL or local path.
*/
export async function fetch(path, options?) {
export async function fetchJson(path, options?): Promise<any> {
if (typeof window !== 'undefined') {
return (window as any).fetch(path, options);
return (window as any).fetch(path, options).then((r) => r.json());
} else if (path.lastIndexOf('http', 0) !== 0) {
try { // UI with SSR sometimes can't find `fs` module, but it's not needed
return require('fs').promises.readFile(path, 'utf8').then((d) => JSON.parse(d));
} catch (e) {
return null;
}
} else {
return require('node-fetch')(path, options);
return require('node-fetch')(path, options).then((r) => r.json());
}
}

@@ -14,5 +14,5 @@ import { Spec } from '@hayspec/spec';

ctx.true(!!utils.toTuple);
ctx.true(!!utils.fetch);
ctx.true(!!utils.fetchJson);
});
export default spec;
import { Spec } from '@hayspec/spec';
import { fetch } from '../../methods/fetch';
import * as path from 'path';
import { fetchJson } from '../../methods/fetch';

@@ -7,6 +8,11 @@ const spec = new Spec();

spec.test('downloads a remote file', async (ctx) => {
const res = await fetch('https://docs.0xcert.org/xcert-mock.json').then((r) => r.json());
const res = await fetchJson('https://docs.0xcert.org/xcert-mock.json');
ctx.true(!!res.XcertMock);
});
spec.test('reads a local file', async (ctx) => {
const res = await fetchJson(path.join(__dirname, '..', 'mocks', 'xcert-mock.json'));
ctx.true(!!res.XcertMock);
});
export default spec;

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