Skip to content

unify isWrapped()

Eugene Lazutkin edited this page Apr 3, 2026 · 1 revision

Checks if a value is wrapped (open, soft, or any other wrap type).

Introduction

Type guard function to check if a value is a Wrap instance. Wrap objects are created by open(), soft(), and other wrapper functions.

import {open, soft, isWrapped} from 'deep6/unify.js';

const openObj = open({a: 1});
const softObj = soft({b: 2});

isWrapped(openObj); // true
isWrapped(softObj); // true
isWrapped({a: 1}); // false - plain object
isWrapped(null); // false
isWrapped('string'); // false

API

isWrapped(o)

Arguments:

  • o — any value to check.

Returns true if o is a Wrap instance, false otherwise.

Details

This is the most general check for wrapped objects. For more specific checks:

  • isOpen() — check specifically for "open" wrap
  • isSoft() — check specifically for "soft" wrap

Wrapped objects have these characteristics:

  • They are instances of the internal Wrap class
  • They have a type property indicating the wrap type
  • They have an object property containing the wrapped value

See Also

  • open() — wrap an object as "open".
  • soft() — wrap an object as "soft".
  • isOpen() — check if wrapped as "open".
  • isSoft() — check if wrapped as "soft".

Clone this wiki locally