webidl-conversions
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -5,4 +5,16 @@ var conversions = {}; | ||
var global_String = String; | ||
var Number_isFinite = Number.isFinite; | ||
conversions["boolean"] = val => !!val; | ||
conversions["DOMString"] = val => global_String(val); | ||
conversions["double"] = val => { | ||
var asNumber = +val; | ||
if (!Number_isFinite(asNumber)) { | ||
throw new TypeError("Argument is not a finite floating-point value."); | ||
} | ||
return asNumber; | ||
}; |
{ | ||
"name": "webidl-conversions", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Implements the WebIDL algorithms for converting to and from JavaScript values", | ||
@@ -9,6 +9,3 @@ "main": "lib/index.js", | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/domenic/webidl-conversions" | ||
}, | ||
"repository": "domenic/webidl-conversions", | ||
"keywords": [ | ||
@@ -25,7 +22,6 @@ "webidl", | ||
"license": "BSD-2-Clause", | ||
"bugs": "https://github.com/domenic/webidl-conversions/issues", | ||
"devDependencies": { | ||
"mocha": "^1.21.4", | ||
"mocha-traceur": "domenic/mocha-traceur#patch-1", | ||
"traceur": "^0.0.58" | ||
"mocha-traceur": "^2.0.0", | ||
"traceur": "^0.0.66" | ||
}, | ||
@@ -32,0 +28,0 @@ "browserify": { |
@@ -29,6 +29,8 @@ # WebIDL Type Conversions on JavaScript Values | ||
So far only `boolean` and `DOMString` types are implemented. This list will grow over time in service of the [HTML as Custom Elements](https://github.com/dglazkov/html-as-custom-elements) project, but in the meantime, pull requests welcome! | ||
So far only `boolean`, `DOMString`, and `double` types are implemented. This list will grow over time in service of the [HTML as Custom Elements](https://github.com/dglazkov/html-as-custom-elements) project, but in the meantime, pull requests welcome! | ||
I'm not sure yet what the strategy will be for modifiers, e.g. [`[Clamp]`](http://heycam.github.io/webidl/#Clamp). Maybe something like `conversions["unsigned long"](x, { clamp: true })`? We'll see. | ||
We might also want to extend the API to give better error messages, e.g. "Argument 1 of HTMLMediaElement.fastSeek is not a finite floating-point value" instead of "Argument is not a finite floating-point value." This would require passing in more information to the conversion functions than we currently do. | ||
## Background | ||
@@ -35,0 +37,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
7844
13
54
0
1