
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
is-function-pure
Advanced tools
is-function-pure is a JavaScript utility for detecting if function is pure.
To install the package, use npm:
npm install is-function-pure
The isPure function checks if a single function in the given code is pure. It returns true if the function is pure, and false otherwise.
Input: A string containing a single JavaScript function.
Output: A boolean indicating whether the function is pure.
const { isPure } = require('is-function-pure');
const pureFunction = `
function multiply(a, b) {
return a * b;
}
`;
console.log(isPure(pureFunction)); // Output: true
The separate function analyzes a block of code and returns an object containing two arrays: pure and impure. Each array holds details about the functions found in the code.
Input: A string containing JavaScript code.
Output: An object with pure and impure arrays.
const { separate } = require('is-function-pure');
const code = `
const x = 5;
function add(a, b) {
return a + b;
}
function impure(a) {
return a + x;
}
`;
const result = separate(code);
console.log('Pure Functions:', result.pure);
console.log('Impure Functions:', result.impure);
More about what is considered pure or not you can read in test cases: https://github.com/senad87/is-function-pure/blob/main/tests/main-test.js https://github.com/senad87/is-function-pure/blob/main/tests/purity-detector-test.js
Tests are written using chai and can be run with:
npm run test
Love this project? ❤️ Support its development by becoming a sponsor.
Any amount is greatly appreciated! 🌟
FAQs
A utility to check if a JavaScript function is pure.
We found that is-function-pure demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.