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 oft miss.
semishuffle
Advanced tools
An array-like object, with automatic looping and configurable entropy
An array-like object with automatic looping and controllable entropy. Useful for stuff like semi-random shuffled music playlists (wherein you'll want the last-played song to go near the end of the list, but not necessarily in the same order as before).
An internal array is maintained, comprising a number of "real" items and a variable number of blank spots.
[ 1, 2, 3, 4, 5, 6, blank, blank, blank ]
When instance.next() is executed, the first (real) entry from the array is removed
[ 2, 3, 4, 5, 6, blank, blank, blank ]
and replaces a random blank spot near the end of the array.
[ 2, 3, 4, 5, 6, blank, 1, blank ]
An additional blank spot is created at the end.
[ 2, 3, 4, 5, 6, blank, 1, blank, blank ]
This process repeats through the first cycle of the items, at which point it's likely a reasonable level of entropy has occurred.
[ 3, 4, 5, 6, blank, 1, blank, 2, blank ]
[ 4, 5, 6, blank, 1, blank, 2, 3, blank ]
[ 5, 6, blank, 1, 4, 2, 3, blank, blank ]
[ 6, blank, 1, 4, 2, 3, blank, 5, blank ]
[ blank, 1, 4, 2, 3, 6, 5, blank, blank ]
If a blank spot ever makes it to the head of the array, it's just automatically cycled back to the end.
Creates a new instance, starting with an array of items and an optional options hash. Default options include:
{
// Shuffle initial array upon instantiation?
shuffleOnInsert: true,
// Initial level of blank spots
variance: .25
}
Changes the number of blank spots in the array.
If the variance value is set >= 1, you're specifiying a whole, specific number of blank spots to use in the array.
If the variance value is set < 1, you're specifying a ratio compared to the number of real items in the collection. (10 item array * .3 variance = 3 blank spots)
If the number of blank spots would change as a result of this, they'll be either added on to the end of the array, or removed from nearest to the beginning.
Retrieves the next item in the array, and then replaces it back in one of the open blank spots. (Afterwards, adds an additional blank spot to the end of the array.) Passing in an optional number of items will do this process N times and return an array of the results.
Work like normal arrays, removing the specified item from the array (or adding it). Rebalances blank spots if necessary. .pop and .shift() will always return a real item (or undefined
), never a blank.
Works like a normal array, except it's non-mutative now, because Array.reverse being mutative is kinda dumb.
Returns a standard array of items in the current order.
Returns the next item, without being mutative. Passing in an optional number of items will return the an array containing the next N items.
Adds the item (or each item in the array) to a random spot in the array.
Fisher-Yates shuffles the existing array, and resets the position of all blank spots to the end.
In case you're not into that whole new ClassName thing, we'll do it for you!
Fisher-Yates shuffles any array for you.
ES6 classes don't really do private, closure-style variables. Anything prefixed by an underscore you probably shouldn't mess with if you want things to, like, work.
FAQs
An array-like object, with automatic looping and configurable entropy
We found that semishuffle 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 oft 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.