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 validation utility that accurately distinguishes genuine Buffer objects from impostor objects with buffer-like properties.
The validator should:
true for genuine Buffer objectsfalse for objects with misleading isBuffer properties (non-function values, methods that don't actually validate Buffers, etc.)Buffer.alloc(10), the validator returns true @testBuffer.from([1, 2, 3]), the validator returns true @test{ isBuffer: null }, the validator returns false @test{ isBuffer: function() { return true; } }, the validator returns false @test{ constructor: { isBuffer: 'not-a-function' } }, the validator returns false @testnull, the validator returns false without throwing an error @testundefined, the validator returns false without throwing an error @test{}, the validator returns false @test@generates
/**
* Validates whether an object is a genuine Buffer
* @param {*} obj - The object to validate
* @returns {boolean} true if obj is a Buffer, false otherwise
*/
function validateBuffer(obj) {
// Implementation here
}
module.exports = { validateBuffer };Provides Buffer type detection functionality.
@satisfied-by
docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9