Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
helper-methods-js
Advanced tools
A package that provides helper methods for common and not-so-common use cases
A package that provides helper methods for common and not-so-common use cases
npm install helper-methods-js
deepcopy
This method creates a deep copy of the provided object to the given depth. Beyond that depth, the object is shallow copied
Parameter | Description | Default Value |
---|---|---|
obj | The object to be copied | N/A |
max_depth (optional) | Maximum depth to which the function would copy the object. Beyond this depth shallow copies would be created. A value of 0 implies that the entire object should be deep copied. | 0 |
import { deepcopy } from 'helper-methods-js'
deepcopy({ name: 'bob' }, 0);
dedupe
This method provides implementation to remove duplicates from an array.
Parameter | Description | Default Value |
---|---|---|
array | The array that needs duplicates removed | N/A |
condition (optional) | A function that returns either true or false . This condition is executed for each array value and the values for which it returns true are removed. In case this condition is not provided, elements are removed on equality comparison. | N/A |
import { dedupe } from 'helper-methods-js'
const cars = [
{ name: "audi", owner: "a" },
{ name: "bmw", owner: "x" },
{ name: "audi", owner: "b" },
{ name: "bmw", owner: "b" },
];
dedupe(cars, (e, i) => e.owner === i.owner)
indexesOf
This method provides implementation to return indexes of all elements that match a specific condition
Parameter | Description | Default Value |
---|---|---|
array | The array that needs duplicates removed | N/A |
condition | It can either be a value or a functions. In case of a function, the function should return true or false . This condition is executed for each array value and the values for which it returns true are added to the list of indexes returned. In case this condition is not provided, elements are removed on equality comparison. | N/A |
import { indexesOf } from 'helper-methods-js'
const objs = [
{ age: 21, nationality: "a" },
{ age: 24, nationality: "a" },
{ age: 21, nationality: "b" },
{ age: 32, nationality: "c" },
{ age: 42, nationality: "b" },
{ age: 52, nationality: "c" },
{ age: 21, nationality: "a" },
]
const indexes = indexesOf(objs, (i: any) => i.nationality === "b")
isAsyncFunction
This method returns whether a function is async or not.
Parameter | Description | Default Value |
---|---|---|
fn | The function for which it needs to be determined whether it is async or not. | N/A |
import { isAsyncFunction } from 'helper-methods-js'
const testFn = async () => {};
isAsyncFunction(testFn) // returns true
const testFnSync = () => {};
isAsyncFunction(testFnSync) // returns false
trimDelimeters
This method takes a string and removes the provided delimeters from the start and end of the string.
Parameter | Description | Default Value |
---|---|---|
str | The string to be trimed | N/A |
delimeters | A list of delimeters to be trimned from the start and/or end of the string provided. | N/A |
options (optional) | An object with values trimStart and trimEnd that represent if the string should only be trimmed from start and/or end respectively. | { trimStart: true, trimEnd: true } |
import { trimDelimeters } from 'helper-methods-js'
trimDelimeters("&&*ABC*(&", ["&", "*"]) // outputs "ABC*("
FAQs
A package that provides helper methods for common and not-so-common use cases
The npm package helper-methods-js receives a total of 3 weekly downloads. As such, helper-methods-js popularity was classified as not popular.
We found that helper-methods-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.