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-alpha3 to 2.0.0-alpha4

.nyc_output/a4a048f8-dd25-457a-b257-c1637eca591e.json

4

CHANGELOG.json

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

{
"version": "2.0.0-alpha3",
"tag": "@0xcert/utils_v2.0.0-alpha3",
"version": "2.0.0-alpha4",
"tag": "@0xcert/utils_v2.0.0-alpha4",
"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-alpha3
## 2.0.0-alpha4
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>;

@@ -11,13 +11,18 @@ "use strict";

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) {
return new Promise((resolve, reject) => {
require('fs').readFile(path, 'utf8', (err, data) => err ? reject(err) : resolve(JSON.parse(data)));
});
}
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

@@ -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

@@ -12,9 +12,14 @@ "use strict";

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());
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(this, 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
{
"files": {},
"arguments": "npm run clean && npx tsc "
"files": {
"packages/0xcert-utils/CHANGELOG.json": "5baac3da69611b6f10266ee6b60fd11643fc5eab",
"packages/0xcert-utils/CHANGELOG.md": "cea8accc586df731d565b76c80b03e784fd64129",
"packages/0xcert-utils/README.md": "12c39c4428dd2fa3e5f419b7e3ae1ebacf1148f1",
"packages/0xcert-utils/nodemon.json": "82b893373db9861f1df4b55d8ea68a5d37b118de",
"packages/0xcert-utils/package.json": "08863d287f15e365f47bf1785356e3f75850965d",
"packages/0xcert-utils/src/index.ts": "a40a59e4ffc9b7099602a46f9680dffb6e307f6e",
"packages/0xcert-utils/src/methods/fetch.ts": "78dcb8cd401756cfc1061f52552f8e7e53db5819",
"packages/0xcert-utils/src/methods/keccak.ts": "70bffccd2fa45a110d794c445d5ba8c152b8eb32",
"packages/0xcert-utils/src/methods/sha.ts": "c0aff1e1a2107310783b874f7a1b1a4d0fe4d6e8",
"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": "d3f4d7ec5dc4ddf378405f2dfcc92644997ec883",
"packages/0xcert-utils/src/tests/methods/fetch.test.ts": "466aa7acd6ea3a60df81d2faf8a60d704ca588dd",
"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/src/tests/mocks/xcert-mock.json": "c5e5a28442cc4df6ff86246f3d64dceca038f62c",
"packages/0xcert-utils/tsconfig.json": "aaa461c172cf0c93d58ffeef8e3ead76fe299b2e",
"packages/0xcert-utils/tslint.json": "c57b3f0cdb7aa74ab2ab02888380f613589cbe66",
"common/config/rush/npm-shrinkwrap.json": "2f2d9986f7c1d779a61e645ffd67426c179b336e"
},
"arguments": "npm run lint && npx nyc npx hayspec test "
}
{
"name": "@0xcert/utils",
"version": "2.0.0-alpha3",
"version": "2.0.0-alpha4",
"description": "General utility module with common helper functions.",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

/**
* 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) {
return new Promise((resolve, reject) => {
require('fs').readFile(path, 'utf8', (err, data) => err ? reject(err) : resolve(JSON.parse(data)));
});
} 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

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