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-9/

Safe Type Validator

A utility library that safely validates data types without throwing errors on null or undefined inputs.

Overview

Create a validation utility that can check if values are of specific types while gracefully handling null and undefined inputs. The validator should never throw errors when given null or undefined values, but instead return false.

Capabilities

Validates buffer types safely

  • When given a Buffer instance, returns true @test
  • When given null, returns false without throwing an error @test
  • When given undefined, returns false without throwing an error @test
  • When given a non-Buffer value like a string "test", returns false @test

Validates array types safely

  • When given an array [1, 2, 3], returns true @test
  • When given null, returns false without throwing an error @test
  • When given undefined, returns false without throwing an error @test

Validates plain object types safely

  • When given a plain object { key: "value" }, returns true @test
  • When given null, returns false without throwing an error @test
  • When given undefined, returns false without throwing an error @test
  • When given an array, returns false (arrays are not plain objects) @test

Implementation

@generates

API

/**
 * Validates if a value is a Buffer.
 * Safely handles null and undefined without throwing errors.
 *
 * @param {any} value - The value to check
 * @returns {boolean} true if value is a Buffer, false otherwise
 */
function isBuffer(value) {
  // IMPLEMENTATION HERE
}

/**
 * Validates if a value is an array.
 * Safely handles null and undefined without throwing errors.
 *
 * @param {any} value - The value to check
 * @returns {boolean} true if value is an array, false otherwise
 */
function isArray(value) {
  // IMPLEMENTATION HERE
}

/**
 * Validates if a value is a plain object.
 * Safely handles null and undefined without throwing errors.
 * Returns false for arrays, functions, and other non-plain objects.
 *
 * @param {any} value - The value to check
 * @returns {boolean} true if value is a plain object, false otherwise
 */
function isPlainObject(value) {
  // IMPLEMENTATION HERE
}

module.exports = {
  isBuffer,
  isArray,
  isPlainObject
};

Dependencies { .dependencies }

is-buffer { .dependency }

Provides Buffer type detection with null/undefined safety.

@satisfied-by

tile.json