graphql-timezone
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -8,2 +8,3 @@ import { GraphQLEnumType } from 'graphql'; | ||
export default _default; | ||
export declare const enumToString: (enumik: string) => string | undefined; | ||
export { timezones, timezoneOptions } from "./timezones"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.timezoneOptions = exports.timezones = void 0; | ||
exports.timezoneOptions = exports.timezones = exports.enumToString = void 0; | ||
var graphql_1 = require("graphql"); | ||
@@ -14,4 +14,10 @@ var timezones_1 = require("./timezones"); | ||
}); | ||
exports.enumToString = function (enumik) { | ||
var object = timezones_1.timezoneOptions.find(function (item) { return item.value === enumik; }); | ||
if (object) | ||
return object.label; | ||
return undefined; | ||
}; | ||
var timezones_2 = require("./timezones"); | ||
Object.defineProperty(exports, "timezones", { enumerable: true, get: function () { return timezones_2.timezones; } }); | ||
Object.defineProperty(exports, "timezoneOptions", { enumerable: true, get: function () { return timezones_2.timezoneOptions; } }); |
10
index.ts
import { GraphQLEnumType } from 'graphql'; | ||
import { TimezoneValues as values } from './timezones'; | ||
import { timezoneOptions, TimezoneValues as values } from './timezones'; | ||
@@ -16,2 +16,10 @@ type Props = { | ||
export const enumToString = (enumik: string) => { | ||
const object = timezoneOptions.find((item) => item.value === enumik); | ||
if (object) return object.label; | ||
return undefined; | ||
}; | ||
export { timezones, timezoneOptions } from "./timezones"; |
{ | ||
"name": "graphql-timezone", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Timezone enum type for GraphQL", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -27,2 +27,31 @@ # GraphQL Timezone | ||
## Bonus - values for select | ||
``` | ||
import { timezoneOptions } from 'graphql-timezone'; | ||
const options = timezoneOptions; | ||
/* | ||
export const timezoneOptions = [ | ||
{ | ||
label: "Africa/Abidjan", | ||
value: "AfricaAbidjan", | ||
}, | ||
... | ||
] | ||
*/ | ||
``` | ||
## Bonus - translate enum to string | ||
``` | ||
import { enumToString } from 'graphql-timezone'; | ||
const label = enumToString("AfricaAbidjan"); // Africa/Abidjan | ||
``` | ||
## Enum details | ||
@@ -29,0 +58,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
319227
9991
1847