CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-is-buffer

Determine if an object is a Buffer without including the full buffer module

93

1.02x
Quality

Pending

Does it follow best practices?

Impact

93%

1.02x

Average score across 9 eval scenarios

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

task.mdevals/scenario-3/

Buffer Validator

Build a validation utility that accurately distinguishes genuine Buffer objects from impostor objects with buffer-like properties.

Requirements

The validator should:

  • Return true for genuine Buffer objects
  • Return false for objects with misleading isBuffer properties (non-function values, methods that don't actually validate Buffers, etc.)
  • Safely handle null, undefined, and primitive types without throwing errors

Test Cases

  • Given Buffer.alloc(10), the validator returns true @test
  • Given Buffer.from([1, 2, 3]), the validator returns true @test
  • Given an object { isBuffer: null }, the validator returns false @test
  • Given an object { isBuffer: function() { return true; } }, the validator returns false @test
  • Given an object with constructor { constructor: { isBuffer: 'not-a-function' } }, the validator returns false @test
  • Given null, the validator returns false without throwing an error @test
  • Given undefined, the validator returns false without throwing an error @test
  • Given a plain object {}, the validator returns false @test

Implementation

@generates

API

/**
 * 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 };

Dependencies { .dependencies }

is-buffer { .dependency }

Provides Buffer type detection functionality.

@satisfied-by

tile.json