
Research
SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.
Slices foo any way you'd like
$ npm install --save slice-foo
Written in ES6 and uses generators so you'll need Node 6 or a transpiler to use it.
const sliceFoo = require('slice-foo')
sliceFoo.slice([4, 4, 4, 4], '4040414142424343')
//=> ['4040', '4141', '4242', '4343']
// It's curried so you can do compose functions like
const parseCardNumber = sliceFoo.slice([4, 4, 4, 4])
parseCardNumber('4040414142424343')
//=> ['4040', '4141', '4242', '4343']
parseCardNumber('4040414142')
//=> ['4040', '4141', '42']
parseCardNumber('40404141')
//=> ['4040', '4141']
// easily join into the format you'd like
parseCardNumber('4040414142424343').join(' ')
//=> '4040 4141 4242 4343'
Read the tests to see how it behaves.
Sliceable: A type that implements .slice (eg. Array and String)
slice :: [Number] -> Sliceable -> [a]
Slices a sliceable into chunks specified by an array of numbers
const sliceFoo = require('slice-foo')
sliceFoo.slice([4, 4, 4, 4], '4040414142424343')
//=> ['4040', '4141', '4242', '4343']
sliceWith :: (() -> Number) -> Sliceable -> [a]
Slices a sliceable into chunks using a function
const sliceFoo = require('slice-foo')
let i = 0
const getChuckSize = () => {
if (i++ % 2 === 0)
return 4
else
return 2
}
sliceFoo.sliceWith(getChuckSize, '4040414142424343')
//=> ['4040', '41', '4142', '42', '4343']
sliceWithGenerator :: (function* -> Number) -> Sliceable -> [a]
Slices a sliceable into chunks using a generator
const sliceFoo = require('slice-foo')
function* chunkGenerator () {
let n = 0
while (n++ < 2)
yield 4
}
sliceFoo.sliceWithGenerator(chunkGenerator, '4040414142424343')
//=> ['4040', '4141']
I needed a module to format strings and found most modules do too many things. It's built to be useful on it's own and composed into more specific functions. Aaand I wanted to publish my first open source project ☝️
MIT © Sindre Seppola
FAQs
Slices foo any way you'd like
We found that slice-foo 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.

Research
An emerging npm supply chain attack that infects repos, steals CI secrets, and targets developer AI toolchains for further compromise.

Company News
Socket is proud to join the OpenJS Foundation as a Silver Member, deepening our commitment to the long-term health and security of the JavaScript ecosystem.

Security News
npm now links to Socket's security analysis on every package page. Here's what you'll find when you click through.