
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.
aoc-toolbox
Advanced tools
This is a small utility to read an input data file from an Advent of Code problem, and offer a set of alternatives on how to extract and handle the data.
The AoC problems start with a file of input data (input.txt), which need to be parsed and handled. After that, of course, there is solving the actual problem, but you won't even get that far until you've decided how to get data in.
The AoC Toolbox is currently only one class, InputData which reads the datafile and allows you to access the data in different ways, depending on how it is structured.
So, which typical input data structures will InputData be useful with? Here is a summary:
InputData.lines() method to access.InputData.linesInts() to access.InputData.linefieldsSeparator().InputData.linefieldsRegexp().InputData.sections() to be able to handle each section separately.InputData.matrixChar() and InputData.subMatrix() respectively.Many of the above methods actually return a new InputData instance instead of raw data, allowing the use cases above to be chained in a string of steps.
There are also other ways to extract a subset of the data to operate on further:
InputData.filterLines() method. There is also a special case of this, to filter out lines matching the value of a character in a given column, InputData.filterOnColValue().Assuming the below input.txt, which describes a number of teams, separated in sections. First line in each section is team name, second line is team members and their ages:
The Wonderboys
carl:12 jonas:47 doug:38
The Fast Ladies
karen:51 taylor:21 alicia:28 billie:18
This code extracts these elements in a structured way:
const {InputData} = require('aoc-toolbox')
const aoc = new InputData() // input.txt is default filename
let teamSections = aoc.sections() // assumes sections separated by empty lines
let teams = teamSections.map((team) => {
let teamName = team.lines()[0] // name is in first line
let memberData = team.lines()[1] // get second line as string
let teamMembers = memberData.split(' ').map((m) => {
let mData = m.split(':')
return {name: mData[0], age: parseInt(mData[1])}
})
return {teamName, teamMembers}
})
console.log(JSON.stringify(teams, null, 2))
The code above will print out this:
[
{
"teamName": "The Wonderboys",
"teamMembers": [
{
"name": "carl",
"age": 12
},
{
"name": "jonas",
"age": 47
},
{
"name": "doug",
"age": 38
}
]
},
{
"teamName": "The Fast Ladies",
"teamMembers": [
{
"name": "karen",
"age": 51
},
{
"name": "taylor",
"age": 21
},
{
"name": "alicia",
"age": 28
},
{
"name": "billie",
"age": 18
}
]
}
]
FAQs
Various useful tools for solving Advent of Code problems
We found that aoc-toolbox 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
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.