Determine if an object is a Buffer without including the full buffer module
93
Pending
Does it follow best practices?
Impact
93%
1.02xAverage score across 9 eval scenarios
Pending
The risk profile of this skill
Build a utility function that checks whether inputs are Buffer objects for a file processing system. The system needs to determine if incoming data is binary (Buffer) or needs conversion.
Create a function checkBinaryData(data) that:
Returns a result object with two properties:
isBinary: boolean that is true if the input is a Buffer, false otherwiseneedsConversion: boolean that is true if the input is not a Buffer (needs conversion to Buffer)Handles various input types safely:
Buffer.from(), Buffer.alloc(), etc.Works without throwing errors for any input type
{ isBinary: true, needsConversion: false } for Buffer.alloc(10) @test{ isBinary: true, needsConversion: false } for Buffer.from([1, 2, 3]) @test{ isBinary: false, needsConversion: true } for string "hello" @test{ isBinary: false, needsConversion: true } for null @test{ isBinary: false, needsConversion: true } for array [1, 2, 3] @test@generates
/**
* Checks if data is binary (Buffer) format.
*
* @param {any} data - The data to check
* @returns {Object} Result with isBinary and needsConversion properties
*/
function checkBinaryData(data) {
// IMPLEMENTATION HERE
}
module.exports = { checkBinaryData };Provides lightweight Buffer type detection without requiring the full Buffer module.
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9