can-data-types
Advanced tools
Comparing version
@@ -1,53 +0,2 @@ | ||
var dataTypes = require("./can-data-types"); | ||
var QUnit = require("steal-qunit"); | ||
var canReflect = require("can-reflect"); | ||
var canSymbol = require("can-symbol"); | ||
var MaybeNumber = dataTypes.MaybeNumber; | ||
var isMemberSymbol = canSymbol.for("can.isMember"); | ||
QUnit.module('can-data-types'); | ||
QUnit.test('MaybeBoolean', function(){ | ||
QUnit.equal( canReflect.convert("true", dataTypes.MaybeBoolean), true, "converted"); | ||
QUnit.equal(canReflect.new(dataTypes.MaybeBoolean, "true") , true); | ||
QUnit.equal(dataTypes.MaybeBoolean[Symbol.for("can.isMember")](true) , true); | ||
QUnit.equal(dataTypes.MaybeBoolean[Symbol.for("can.isMember")]("true") , false); | ||
QUnit.equal(dataTypes.MaybeBoolean[Symbol.for("can.isMember")](null) , true); | ||
}); | ||
QUnit.test('MaybeDate', function(){ | ||
var date = new Date(2018,0,1); | ||
QUnit.equal( canReflect.convert(date.toString(), dataTypes.MaybeDate).getTime(), date.getTime(), "converted"); | ||
QUnit.deepEqual(canReflect.new(dataTypes.MaybeDate, "2018-1-31") , new Date( Date.parse("2018-1-31") ), "new" ); | ||
QUnit.equal(dataTypes.MaybeDate[Symbol.for("can.isMember")](new Date()) , true); | ||
QUnit.equal(dataTypes.MaybeDate[Symbol.for("can.isMember")]({}) , false); | ||
QUnit.equal(dataTypes.MaybeDate[Symbol.for("can.isMember")](null) , true); | ||
}); | ||
QUnit.test('MaybeNumber', function(){ | ||
QUnit.equal( canReflect.convert("5", MaybeNumber), 5, "converted"); | ||
QUnit.equal( canReflect.new(MaybeNumber, "1"), 1); | ||
QUnit.equal( MaybeNumber[isMemberSymbol](1) , true); | ||
QUnit.equal( MaybeNumber[isMemberSymbol]("1") , false); | ||
QUnit.equal( MaybeNumber[isMemberSymbol](null) , true); | ||
}); | ||
QUnit.test('MaybeString', function(){ | ||
QUnit.equal( canReflect.convert(1, dataTypes.MaybeString), "1", "converted"); | ||
QUnit.equal( canReflect.new(dataTypes.MaybeString, 1) , "1"); | ||
QUnit.equal( dataTypes.MaybeString[Symbol.for("can.isMember")]("1") , true); | ||
QUnit.equal( dataTypes.MaybeString[Symbol.for("can.isMember")](1) , false); | ||
QUnit.equal( dataTypes.MaybeString[Symbol.for("can.isMember")](null) , true); | ||
}); | ||
require("./test/can-data-types-test"); | ||
require("./test/can-data-types-maybe-test"); |
@@ -6,3 +6,4 @@ "use strict"; | ||
MaybeString = require("./maybe-string/maybe-string"), | ||
namespace = require("can-namespace"); | ||
namespace = require("can-namespace"), | ||
types = require("./types"); | ||
@@ -13,3 +14,7 @@ module.exports = namespace.dataTypes = { | ||
MaybeNumber: MaybeNumber, | ||
MaybeString: MaybeString | ||
MaybeString: MaybeString, | ||
maybe: types.maybe, | ||
maybeConvert: types.maybeConvert, | ||
check: types.check, | ||
convert: types.convert | ||
}; |
{ | ||
"name": "can-data-types", | ||
"version": "1.2.0", | ||
"version": "1.3.0-pre.0", | ||
"description": "Reusable special data types", | ||
@@ -52,8 +52,8 @@ "homepage": "", | ||
"jshint": "^2.9.1", | ||
"steal": "^1.6.5", | ||
"steal": "^2.2.1", | ||
"steal-qunit": "^1.0.1", | ||
"steal-tools": "^1.11.3", | ||
"testee": "^0.7.0" | ||
"steal-tools": "^2.2.1", | ||
"testee": "^0.9.0" | ||
}, | ||
"license": "MIT" | ||
} |
# can-data-types | ||
[](https://travis-ci.org/canjs/can-data-types) | ||
[](https://www.bitovi.com/community/slack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[](https://forums.bitovi.com/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) | ||
[](https://github.com/canjs/can-data-types/blob/master/LICENSE) | ||
[](https://www.npmjs.com/package/can-data-types) | ||
[](https://travis-ci.org/canjs/can-data-types) | ||
[](https://greenkeeper.io/) | ||
Reusable special data types | ||
## Usage | ||
## Documentation | ||
### ES6 use | ||
Read the [can-data-types API docs on CanJS.com](https://canjs.com/doc/can-data-types.html). | ||
With StealJS, you can import this module directly in a template that is autorendered: | ||
## Changelog | ||
```js | ||
import plugin from 'can-data-types'; | ||
``` | ||
See the [latest releases on GitHub](https://github.com/canjs/can-data-types/releases). | ||
### CommonJS use | ||
## Contributing | ||
Use `require` to load `can-data-types` and everything else | ||
needed to create a template that uses `can-data-types`: | ||
The [contribution guide](https://github.com/canjs/can-data-types/blob/master/CONTRIBUTING.md) has information on getting help, reporting bugs, developing locally, and more. | ||
```js | ||
var plugin = require("can-data-types"); | ||
``` | ||
## License | ||
### Standalone use | ||
Load the `global` version of the plugin: | ||
```html | ||
<script src='./node_modules/can-data-types/dist/global/can-data-types.js'></script> | ||
``` | ||
[MIT](https://github.com/canjs/can-data-types/blob/master/LICENSE) |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
23125
39.03%23
15%385
126.47%2
100%27
-18.18%