chronokinesis
Advanced tools
Comparing version 4.0.1 to 5.0.0
23
index.js
@@ -7,4 +7,2 @@ /** | ||
*/ | ||
'use strict'; | ||
const NativeDate = Date; | ||
@@ -51,12 +49,3 @@ const nativeGetTimezoneOffset = NativeDate.prototype.getTimezoneOffset; | ||
module.exports = { | ||
freeze, | ||
defrost, | ||
travel, | ||
reset, | ||
isKeepingTime, | ||
timezone, | ||
}; | ||
function freeze(...args) { | ||
export function freeze(...args) { | ||
useFakeDate(); | ||
@@ -71,7 +60,7 @@ freezedAt = instantiate(Date, args); | ||
function defrost() { | ||
export function defrost() { | ||
freezedAt = null; | ||
} | ||
function travel(...args) { | ||
export function travel(...args) { | ||
useFakeDate(); | ||
@@ -94,3 +83,3 @@ const travelToDate = instantiate(Date, args); | ||
function reset() { | ||
export function reset() { | ||
useNativeDate(); | ||
@@ -103,7 +92,7 @@ freezedAt = null; | ||
function isKeepingTime() { | ||
export function isKeepingTime() { | ||
return Date === FakeDate; | ||
} | ||
function timezone(timeZone) { | ||
export function timezone(timeZone) { | ||
const options = { | ||
@@ -110,0 +99,0 @@ year: 'numeric', |
{ | ||
"name": "chronokinesis", | ||
"version": "4.0.1", | ||
"version": "5.0.0", | ||
"description": "Module for testing time-dependent code", | ||
@@ -10,5 +10,8 @@ "author": { | ||
"license": "MIT", | ||
"main": "index.js", | ||
"browser": "dist/chronokinesis.js", | ||
"jsnext:main": "dist/index.es.js", | ||
"type": "module", | ||
"module": "index.js", | ||
"main": "dist/main.cjs", | ||
"browser": "dist/chronokinesis.cjs", | ||
"jsnext:main": "index.js", | ||
"sideEffects": true, | ||
"repository": { | ||
@@ -19,8 +22,8 @@ "type": "git", | ||
"scripts": { | ||
"toc": "node generate-api-toc.js", | ||
"toc": "node generate-api-toc.cjs", | ||
"test": "mocha", | ||
"lint": "eslint . --cache", | ||
"test:lcov": "c8 -r lcov mocha && npm run lint", | ||
"test:lcov": "c8 -r lcov -r text mocha && npm run lint", | ||
"posttest": "npm run lint && npm run dist", | ||
"prepublishOnly": "npm run dist", | ||
"prepack": "npm run dist", | ||
"dist": "npm run toc && rollup -c" | ||
@@ -30,4 +33,5 @@ }, | ||
"index.js", | ||
"dist/chronokinesis.js", | ||
"dist/index.es.js" | ||
"index.d.ts", | ||
"dist/chronokinesis.cjs", | ||
"dist/index.cjs" | ||
], | ||
@@ -50,6 +54,3 @@ "bugs": { | ||
"devDependencies": { | ||
"@babel/core": "^7.12.3", | ||
"@babel/preset-env": "^7.12.1", | ||
"@rollup/plugin-babel": "^6.0.3", | ||
"@rollup/plugin-commonjs": "^23.0.4", | ||
"@rollup/plugin-commonjs": "^24.0.1", | ||
"c8": "^7.12.0", | ||
@@ -61,5 +62,5 @@ "chai": "^4.3.7", | ||
"mocha": "^10.1.0", | ||
"moment": "^2.29.1", | ||
"moment": "^2.29.4", | ||
"rollup": "^3.7.0" | ||
} | ||
} |
chronokinesis | ||
============= | ||
[![Build Status](https://app.travis-ci.com/paed01/chronokinesis.svg?branch=master)](https://app.travis-ci.com/paed01/chronokinesis) [![Coverage Status](https://coveralls.io/repos/github/paed01/chronokinesis/badge.svg?branch=master)](https://coveralls.io/github/paed01/chronokinesis?branch=master) | ||
[![Build](https://github.com/paed01/chronokinesis/actions/workflows/build.yaml/badge.svg)](https://github.com/paed01/chronokinesis/actions/workflows/build.yaml) [![Coverage Status](https://coveralls.io/repos/github/paed01/chronokinesis/badge.svg?branch=master)](https://coveralls.io/github/paed01/chronokinesis?branch=master) | ||
@@ -22,4 +22,4 @@ Mock time and date for traveling and freezing. Inspired and borrowed from [timekeeper](https://github.com/vesln/timekeeper). | ||
- [Distributions](#distributions) | ||
- [Browser](#browser) | ||
- [Rollup](#rollup) | ||
- [Nodejs require](#nodejs-require) | ||
- [Browser (UMD)](#browser-umd) | ||
- [Acknowledgements](#acknowledgements) | ||
@@ -34,3 +34,3 @@ | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
import * as ck from 'chronokinesis'; | ||
@@ -50,4 +50,4 @@ ck.freeze(); | ||
```javascript | ||
const moment = require('moment'); | ||
const ck = require('chronokinesis'); | ||
import moment from 'moment'; | ||
import * as ck from 'chronokinesis'; | ||
@@ -73,3 +73,3 @@ ck.travel(moment().add(1, 'year')); | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
import * as ck from 'chronokinesis'; | ||
@@ -93,3 +93,3 @@ ck.freeze('1942-01-08'); | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
import * as ck from 'chronokinesis'; | ||
let date = new Date(2018, 0, 31); | ||
@@ -108,4 +108,4 @@ | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
const moment = require('moment'); | ||
import * as ck from 'chronokinesis'; | ||
import moment from 'moment'; | ||
@@ -130,3 +130,3 @@ let date = new Date(2018, 0, 31); | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
import * as ck from 'chronokinesis'; | ||
@@ -154,3 +154,3 @@ ck.freeze(1980, 0, 1); | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
import * as ck from 'chronokinesis'; | ||
@@ -171,3 +171,3 @@ ck.freeze(2060, 0, 1); | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
import * as ck from 'chronokinesis'; | ||
@@ -184,3 +184,3 @@ console.log(ck.isKeepingTime() ? 'Is' : 'Not', 'keeping time'); | ||
```javascript | ||
const ck = require('chronokinesis'); | ||
import * as ck from 'chronokinesis'; | ||
@@ -210,11 +210,13 @@ const tz = ck.timezone('Asia/Shanghai'); | ||
The module is prepared for browser and [rollup](https://github.com/rollup/rollup). | ||
The module is prepared for browser and nodejs. | ||
## Browser | ||
## Nodejs require | ||
Use `dist/chronokinesis.js`. Sets global property `chronokinesis`. | ||
```js | ||
const ck = require('chronokinesis'); | ||
``` | ||
## Rollup | ||
## Browser (UMD) | ||
`jsnext:main: dist/index.es.js` | ||
Use `dist/chronokinesis.cjs`. Sets global property `chronokinesis`. | ||
@@ -221,0 +223,0 @@ # Acknowledgements |
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
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
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
9
7
215
Yes
21900
530
1