New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

can-reflect

Package Overview
Dependencies
Maintainers
10
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

can-reflect - npm Package Compare versions

Comparing version 1.15.2 to 1.16.0

2

package.json
{
"name": "can-reflect",
"version": "1.15.2",
"version": "1.16.0",
"description": "reflection on unknown data types",

@@ -5,0 +5,0 @@ "homepage": "http://canjs.com",

@@ -179,3 +179,3 @@ var canSymbol = require("can-symbol");

*
* canReflect.cloneKeySort({z: "Z", a: "A"}) //-> {a: "A", z: "Z"}
* canReflect.cloneKeySort({z: "Z", a: "A"}) //-> {a:"A",z:"Z"}
* ```

@@ -194,3 +194,43 @@ *

},
/**
* @function can-reflect.convert convert
* @parent can-reflect/shape
* @description Convert one value to another type.
*
* @signature `convert(value, Type)`
*
* `convert` attempts to convert `value` to the type specified by `Type`.
*
* ```js
* import canRefect from "can-reflect";
*
* canReflect.convert("1", Number) //-> 1
* ```
*
* `convert` works by performing the following logic:
*
* 1. If the `Type` is a primitive like `Number`, `String`, `Boolean`, the
* `value` will be passed to the `Type` function and the result returned.
* ```js
* return Type(value);
* ```
* 2. The value will be checked if it is already an instance of the type
* by performing the following:
* 1. If the `Type` has a `can.isMember` symbol value, that value will be used
* to determine if the `value` is already an instance.
* 2. If the `Type` is a [can-reflect.isConstructorLike] function, `instanceof Type`
* will be used to check if `value` is already an instance.
* 3. If `value` is already an instance, `value` will be returned.
* 4. If `Type` has a `can.new` symbol, `value` will be passed to it and the result
* returned.
* 5. If `Type` is a [can-reflect.isConstructorLike] function, `new Type(value)` will be
* called the the result returned.
* 6. If `Type` is a regular function, `Type(value)` will be called and the result returned.
* 7. If a value hasn't been returned, an error is thrown.
*
* @param {Object|Primitive} value A value to be converted.
* @param {Object|Function} Type A constructor function or an object that implements the
* necessary symbols.
* @return {Object} The `value` converted to a member of `Type`.
*/
convert: function(value, Type){

@@ -197,0 +237,0 @@ if(isPrimitiveConverter(Type)) {

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