Skip to content

Commit

Permalink
fix: improve browser and node integration with vite
Browse files Browse the repository at this point in the history
  • Loading branch information
mtorre4580 committed Dec 17, 2023
1 parent 8cbc556 commit 6bea0fc
Show file tree
Hide file tree
Showing 8 changed files with 834 additions and 9 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A utility library designed to notify about deprecated functions or methods within objects.

![Logo](https://github.com/mtorre4580/is-deprecated/blob/main/deprecated.png?raw=true)
<img width="128" height="128" src="https://github.com/mtorre4580/is-deprecated/blob/main/deprecated.png?raw=true" />

## Installation

Expand Down Expand Up @@ -39,10 +39,10 @@ const config = {
};

// Create the wrapper to use
const deprecatedMyFunction = deprecated(fn, config);
const deprecatedMyFunction = deprecated(myFunction, config);

// Call the wrapper function to see the warning
deprecatedMyFunction(arg1, arg2);
deprecatedMyFunction('', {});
```

### With Function in Object
Expand Down Expand Up @@ -83,5 +83,5 @@ const users = await APIWithDeprecated.getUsers();

- To building time use the jsdoc decorator [@deprecated](https://jsdoc.app/tags-deprecated) in the code
- To runtime use the function from this lib `deprecated` to notify in the console
- The sendMetrics function allows to get more insight what app,frontend or api is using the deprecated lib to notify
- You can use any env variable to apply the wrapper or not to avoid validation only for development, staging environment
- The sendMetrics function allows to get more insight what app is using the deprecated method to notify the team
- You can use any environment variable to apply the wrapper or not, if you only need to run in development or staging
2 changes: 1 addition & 1 deletion __tests__/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const deprecated = require('../lib');
const deprecated = require('../lib/main');

describe('deprecated', () => {
describe('function flow', () => {
Expand Down
101 changes: 101 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto&display=swap"
rel="stylesheet"
/>
<title>is-deprecated</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

:root {
--background-color: #212121;
--font-color: #f5f5f5;
}

body {
font-family: "Roboto", sans-serif;
padding: 2em;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 1em;
height: 100vh;
background-color: var(--background-color);
font-size: 18px;
}

.title {
display: flex;
align-items: center;
color: var(--font-color);
}

.banner {
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
gap: 2em;
color: var(--font-color);

.logo {
max-width: 100%;
height: 128px;
width: 128px;
}
}

a {
color: var(--font-color);
}
</style>
</head>

<body>
<h1 class="title">is-deprecated</h1>
<section class="banner">
<img
alt="logo"
class="logo"
src="https://raw.githubusercontent.com/mtorre4580/is-deprecated/main/deprecated.png"
/>
<p>
A utility library designed to notify about deprecated functions or
methods within objects.
</p>
<p>
<a href="https://github.com/mtorre4580/is-deprecated">Readme</a>
</p>
</section>
<script type="module">
import deprecated from "./dist/is-deprecated.es.js";

// Function to add the deprecated helper
const myFunction = (arg1, arg2) => {};

// Basic config
const config = {
message:
"myFunction will be removed in the next release, please replace with this https://www.npmjs.com",
};

// Create the wrapper to use
const deprecatedMyFunction = deprecated(myFunction, config);

// Call the wrapper function to see the warning
deprecatedMyFunction("", {});
</script>
</body>
</html>
File renamed without changes.
Loading

0 comments on commit 6bea0fc

Please sign in to comment.