Migrating to TypeScript

parent 2d3ab666
.idea
src
tsconfig.json
.yo-rc.json
yarn.lock
......
......@@ -2,8 +2,8 @@
"name": "iscamelcase",
"version": "0.6.6",
"description": "A small package that compares strings with there camelCased counterparts",
"main": "src/index.js",
"types": "./index.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc",
"test": "jest"
......
declare module "iscamelcase" {
export function checkString(input: string): boolean;
export function checkFile(filename: string): boolean;
}
\ No newline at end of file
......@@ -4,17 +4,16 @@
* @Copyright (c) 2018, Marcel Dominic Bandowski.
* Released under the MIT License.
*/
import camelCase from "camelcase";
'use strict';
const camelCase = require("camelcase");
const fileExtension = require("file-extension");
import fileExtension from "file-extension";
/**
* compare the input before and after the conversion
* @param input
* @returns {boolean}
*/
module.exports.checkString = (input) => {
export const checkString = (input: string) => {
return input === camelCase(input);
};
......@@ -23,7 +22,7 @@ module.exports.checkString = (input) => {
* @param input
* @returns {boolean}
*/
module.exports.checkFile = (input) => {
export const checkFile = (input: string) => {
const fileName = input.replace(`.${fileExtension(input, {preserveCase: true})}`, "");
return fileName === camelCase(fileName);
};
\ No newline at end of file
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true
"target": "es2018",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": ".",
"declaration": true,
"declarationDir": "./dist",
"typeRoots": [
"./node_modules/@types",
"./src/typings"
]
},
"exclude": [
"node_modules"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment