chaining-date
Advanced tools
| var ChainingDate=function(){var t=Date;function n(n){this.date="number"==typeof n?new t(n):"string"==typeof n?new t(t.parse(n)):n||new t}var e=n.prototype;return e.add=function(){return this},e.set=function(){return this},e.get=function(){return this.date},e.toString=function(t){var n=this.date;return t?n:n.toString()},n}(); |
| var D = Date; | ||
| function ChainingDate(date) { | ||
| this.date = ( | ||
| typeof date == 'number' ? new D(date) : | ||
| typeof date == 'string' ? new D(D.parse(date)) : | ||
| date ? date : new D() | ||
| ); | ||
| } | ||
| var P = ChainingDate.prototype; | ||
| P.add = function () { | ||
| return this; | ||
| }; | ||
| P.set = function () { | ||
| return this; | ||
| }; | ||
| P.get = function () { | ||
| return this.date; | ||
| }; | ||
| P.toString = function (pattern) { | ||
| var date = this.date; | ||
| if (pattern) { | ||
| return date; | ||
| } | ||
| return date.toString(); | ||
| }; | ||
| export default ChainingDate; |
+31
-31
| /** | ||
| * @author TroyTae | ||
| * @version 0.1.1 | ||
| * @version 0.1.2 | ||
| * @name chaining-date | ||
| */ | ||
| (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f():typeof define==='function'&&define.amd?define(f):(g=g||self,g.ChainingDate=f());}(this,(function(){'use strict';var D = Date; | ||
| var ChainingDate = (function () { | ||
| function ChainingDate(date) { | ||
| if (typeof date == 'number') { | ||
| this.date = new D(date); | ||
| } | ||
| else if (typeof date == 'string') { | ||
| this.date = new D(D.parse(date)); | ||
| } | ||
| else { | ||
| this.date = date; | ||
| } | ||
| } | ||
| ChainingDate.prototype.add = function () { | ||
| return this; | ||
| }; | ||
| ChainingDate.prototype.set = function () { | ||
| return this; | ||
| }; | ||
| ChainingDate.prototype.get = function () { | ||
| return this.date; | ||
| }; | ||
| ChainingDate.prototype.toString = function (pattern) { | ||
| if (pattern) { | ||
| return this.date; | ||
| } | ||
| return this.date.toString(); | ||
| }; | ||
| return ChainingDate; | ||
| }());return ChainingDate;}))); | ||
| 'use strict'; | ||
| var D = Date; | ||
| function ChainingDate(date) { | ||
| this.date = ( | ||
| typeof date == 'number' ? new D(date) : | ||
| typeof date == 'string' ? new D(D.parse(date)) : | ||
| date ? date : new D() | ||
| ); | ||
| } | ||
| var P = ChainingDate.prototype; | ||
| P.add = function () { | ||
| return this; | ||
| }; | ||
| P.set = function () { | ||
| return this; | ||
| }; | ||
| P.get = function () { | ||
| return this.date; | ||
| }; | ||
| P.toString = function (pattern) { | ||
| var date = this.date; | ||
| if (pattern) { | ||
| return date; | ||
| } | ||
| return date.toString(); | ||
| }; | ||
| module.exports = ChainingDate; |
+5
-5
| { | ||
| "name": "chaining-date", | ||
| "version": "0.1.1", | ||
| "version": "0.1.2", | ||
| "description": "A tiny module for using Date with chaining ⏱", | ||
@@ -20,5 +20,4 @@ "main": "dist/index.js", | ||
| "devDependencies": { | ||
| "rollup": "^1.27.5", | ||
| "typescript": "^3.7.2", | ||
| "rollup-plugin-typescript2": "^0.25.2" | ||
| "rollup": "^1.27.8", | ||
| "rollup-plugin-terser": "^5.1.2" | ||
| }, | ||
@@ -33,4 +32,5 @@ "scripts": { | ||
| "time", | ||
| "millisecond" | ||
| "format", | ||
| "chaining" | ||
| ] | ||
| } |
+13
-17
| const pkg = require('./package.json'); | ||
| const typescript = require('rollup-plugin-typescript2'); | ||
| const {terser} = require('rollup-plugin-terser'); | ||
| const output = { | ||
| name: pkg.name | ||
| .split('-') | ||
| .map((v) => v.slice(0, 1).toUpperCase() + v.slice(1)) | ||
| .join(''), | ||
| format: 'umd', | ||
| banner: `/**\n * @author ${pkg.author.name}\n * @version ${pkg.version}\n * @name ${pkg.name}\n */` | ||
| }; | ||
| const createConfig = (isProd) => { | ||
| const createConfig = (isNode) => { | ||
| return { | ||
| input: 'src/index.ts', | ||
| input: 'src/chaining-date.js', | ||
| output: { | ||
| ...output, | ||
| compact: isProd, | ||
| file: pkg.main.replace(isProd ? '' : '.min', '') | ||
| banner: `/**\n * @author ${pkg.author.name}\n * @version ${pkg.version}\n * @name ${pkg.name}\n */`, | ||
| compact: !isNode, | ||
| strict : isNode, | ||
| format: isNode ? 'cjs' : 'iife', | ||
| file: isNode ? pkg.main : `dist/${pkg.name}.js`, | ||
| name: pkg.name.split('-').map((v) => v.slice(0, 1).toUpperCase() + v.slice(1)).join(''), | ||
| }, | ||
| plugins: [ | ||
| typescript({ clean: true }) | ||
| ] | ||
| isNode ? null : terser({ | ||
| compress: { loops: false } | ||
| }) | ||
| ].filter(Boolean) | ||
| }; | ||
@@ -25,0 +21,0 @@ }; |
| declare class ChainingDate { | ||
| date: Date; | ||
| constructor(date: number | string | Date); | ||
| add(): this; | ||
| set(): this; | ||
| get(): Date; | ||
| toString(pattern?: string): string | Date; | ||
| } | ||
| export default ChainingDate; |
| /** | ||
| * @author TroyTae | ||
| * @version 0.0.1 | ||
| * @name chaining-date | ||
| */ | ||
| (function(g,f){typeof exports==='object'&&typeof module!=='undefined'?module.exports=f():typeof define==='function'&&define.amd?define(f):(g=g||self,g.ChainingDate=f());}(this,(function(){'use strict';var D = Date; | ||
| var ChainingDate = (function () { | ||
| function ChainingDate(date) { | ||
| if (typeof date == 'number') { | ||
| this.date = new D(date); | ||
| } | ||
| else if (typeof date == 'string') { | ||
| this.date = new D(D.parse(date)); | ||
| } | ||
| else { | ||
| this.date = date; | ||
| } | ||
| } | ||
| ChainingDate.prototype.add = function () { | ||
| return this; | ||
| }; | ||
| ChainingDate.prototype.set = function () { | ||
| return this; | ||
| }; | ||
| ChainingDate.prototype.get = function () { | ||
| return this.date; | ||
| }; | ||
| ChainingDate.prototype.toString = function (pattern) { | ||
| if (pattern) { | ||
| return this.date; | ||
| } | ||
| return this.date.toString(); | ||
| }; | ||
| return ChainingDate; | ||
| }());return ChainingDate;}))); |
-36
| const D = Date; | ||
| class ChainingDate { | ||
| date: Date; | ||
| constructor(date: number | string | Date) { | ||
| if (typeof date == 'number') { | ||
| this.date = new D(date); | ||
| } else if (typeof date == 'string') { | ||
| this.date = new D(D.parse(date)); | ||
| } else { | ||
| this.date = date; | ||
| } | ||
| } | ||
| add() { | ||
| return this; | ||
| } | ||
| set() { | ||
| return this; | ||
| } | ||
| get() { | ||
| return this.date; | ||
| } | ||
| toString(pattern?: string) { | ||
| if (pattern) { | ||
| return this.date; | ||
| } | ||
| return this.date.toString(); | ||
| } | ||
| } | ||
| export default ChainingDate; |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
2
-33.33%5314
-21.61%9
-10%94
-35.17%3
50%