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

@gql2ts/util

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gql2ts/util - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0-alpha.c9e04a1e

3

dist/fileIO.d.ts
export declare const badWriteHandler: (err?: Error) => void;
export declare const readFile: (fileName: string) => string;
export declare const readFile: (fileName: string) => string | object;
export declare const safeJSONParse: (possibleJSON: string) => string | object;
export declare const writeToFile: (fileName: string, data: string) => void;

@@ -7,4 +7,26 @@ "use strict";

} };
exports.readFile = fileName => JSON.parse(fs.readFileSync(fileName).toString());
exports.readFile = fileName => {
const stringifiedFile = fs.readFileSync(fileName).toString();
if (fileName.endsWith('.json')) {
// force JSON Parse
return JSON.parse(stringifiedFile);
}
else if (fileName.endsWith('.graphql') || fileName.endsWith('.gql')) {
// assume graphql schema language
return stringifiedFile;
}
else {
// fallback when the type is unknown
return exports.safeJSONParse(stringifiedFile);
}
};
exports.safeJSONParse = possibleJson => {
try {
return JSON.parse(possibleJson);
}
catch (e) {
return possibleJson;
}
};
exports.writeToFile = (fileName, data) => fs.writeFile(fileName, data, exports.badWriteHandler);
//# sourceMappingURL=fileIO.js.map

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

export { readFile, writeToFile } from './fileIO';
export { readFile, writeToFile, safeJSONParse } from './fileIO';
export { PossibleIntrospectionInputs, PossibleSchemaInput, isIntrospectionResult, schemaFromInputs, isList, isNonNullable, isEnum } from './schema';

@@ -6,2 +6,3 @@ "use strict";

exports.writeToFile = fileIO_1.writeToFile;
exports.safeJSONParse = fileIO_1.safeJSONParse;
var schema_1 = require("./schema");

@@ -8,0 +9,0 @@ exports.isIntrospectionResult = schema_1.isIntrospectionResult;

{
"name": "@gql2ts/util",
"private": false,
"version": "1.2.2",
"version": "1.3.0-alpha.c9e04a1e",
"description": "utilities for gql2ts",

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

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