Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions isArray.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Deprecation isArray Fix

## Identify the Deprecation Warning

- The `DeprecationWarning: The util.isArray API is deprecated` occurs due to the usage of `util.isArray` in certain libraries.

## Fork the Library on GitHub

- Fork the affected library's repository to your GitHub account (e.g., `[email protected]:YourUsername/library.git`) to make necessary modifications.****

## Clone and Modify the Fork

- Clone the fork to your local machine and replace the deprecated `util.isArray` with `Array.isArray` in the relevant files.

Example change:

```js
// Original code
var isArray = require('util').isArray;

// Modified code
var isArray = Array.isArray;
```

## Create a Patch for the Fix

- Use `patch-package` to create a patch after modifying the code. This allows the fix to be reapplied after each package installation.

### Install patch-package

- Run the following command:

```bash
npm install patch-package postinstall-postinstall
```

### Apply the Fix with patch-package

- Create and apply the patch with:

```bash
npx patch-package library
```

### Set postinstall Script

- Add a postinstall script in `package.json` to ensure the patch is reapplied automatically:

```json
"scripts": {
"postinstall": "patch-package"
}
```

## Install Dependencies

- Run `npm install` to apply the patch and install the necessary dependencies.

## Update Package Dependency

- Modify your project's `package.json` to use the forked version of the library:

```json
"dependencies": {
"connect-flash": "git+ssh://[email protected]:YourUsername/library.git"
}
```

## Install the Forked Version

- Execute `npm install` to install the library from your forked repository.

## Test the Fix

- Ensure the deprecation warning is resolved and your application runs without any issues.
5 changes: 2 additions & 3 deletions lib/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
* Module dependencies.
*/
var format = require('util').format;
var isArray = require('util').isArray;

var isArray = Array.isArray;

/**
* Expose `flash()` function on requests.
Expand All @@ -14,7 +13,7 @@ var isArray = require('util').isArray;
module.exports = function flash(options) {
options = options || {};
var safe = (options.unsafe === undefined) ? true : !options.unsafe;

return function(req, res, next) {
if (req.flash && safe) { return next(); }
req.flash = _flash;
Expand Down
38 changes: 38 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.