Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

can-reflect

Package Overview
Dependencies
Maintainers
2
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-reflect

reflection on unknown data types

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.4K
increased by38.77%
Maintainers
2
Weekly downloads
 
Created
Source

can-reflect

Build Status

Reflect allows you to reflection on unknown data types.

By looking for symbols in [can-symbol], can-reflect lets someone act upon any data type without having to have prior knowledge of it.

var Thing = function(){

};
Thing.prototype.method = function(){}

var canReflect = require("can-reflect");
canReflect.isConstructorLike(Thing) //-> true

The different reflections you can use are grouped by reflection type as follows:

  • Type Reflections - Tell you what the value is.
    • .isConstructorLike
    • .isFunctionLike
    • .isIteratorLike
    • .isListLike
    • .isMapLike
    • .isMoreListThanMapLike (lists can often still be maps)
    • .isObservableLike
    • .isValueLike
    • .isSymbolLike
  • Shape Reflections - Give you information about the value.
    • own and enumerable
      • .eachIndex
      • .eachKey
      • .each
      • .getOwnEnumerableKeys (aka .keys)
      • .toArray
    • own
      • .getOwnKeys
      • .getOwnKeyDescriptor
    • all (pending)
  • Getter / Setter Reflections - get or set some value on another value.
    • .getKeyValue, .setKeyValue, .deleteKeyValue - for maps (get, set, and delete are aliases)
    • .getValue, .setValue - for things like computes
    • .splice, .addKeys(keyValues[,index]), .removeKeys(keysOrValues[,index]) (PENDING?)
  • Function Reflections - call functions or create instances
    • .call
    • .apply
    • .new
  • Observe Reflections - listen to when things change
    • .onKeyValue, .offKeyValue
    • .onKeys - when anything changes
    • .onKeysAdded, .onKeysRemoved
    • .getKeyDependencies - for debugging
    • .keyHasDependencies
    • .onValue, .offValue
    • .getValueDependencies
    • .valueHasDependencies
    • .onEvent, .offEvent - listen to an event on something

TODO:

  • .deleteKeyValue, .get and .set aliases
  • addKeys / removeKeys
  • isInitializing

Keywords

FAQs

Package last updated on 24 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc