Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vague-time

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vague-time - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

15

component.json
{
"name": "vagueTime.js",
"name": "vague-time",
"repo": "philbooth/vagueTime.js",
"version": "0.4.1",
"version": "0.5.0",
"author": "Phil Booth <pmbooth@gmail.com>",
"description": "A tiny JavaScript library that formats precise time differences as a vague/fuzzy time, e.g. '3 months ago', 'just now' or 'in 2 hours'.",
"contributors": {
"name": "Phil Booth",
"email": "pmbooth@gmail.com"
},
"description": "A tiny library that formats precise time differences as a vague/fuzzy time, e.g. '3 months ago', 'just now' or 'in 2 hours'.",
"contributors": [
{ "name": "Phil Booth", "email": "pmbooth@gmail.com" },
{ "name": "seth-cameo" },
{ "name": "Pepijn de Vos" }
],
"main": "src/vagueTime.min.js",

@@ -12,0 +13,0 @@ "scripts": [

{
"name": "vague-time",
"version": "0.4.1",
"version": "0.5.0",
"author": "Phil Booth <pmbooth@gmail.com>",
"description": "A tiny JavaScript library that formats precise time differences as a vague/fuzzy time, e.g. '3 months ago', 'just now' or 'in 2 hours'.",
"description": "A tiny library that formats precise time differences as a vague/fuzzy time, e.g. '3 months ago', 'just now' or 'in 2 hours'.",
"contributors": [
{
"name": "Phil Booth",
"email": "pmbooth@gmail.com"
},
{
"name": "seth-cameo"
}
{ "name": "Phil Booth", "email": "pmbooth@gmail.com" },
{ "name": "seth-cameo" },
{ "name": "Pepijn de Vos" }
],

@@ -15,0 +11,0 @@ "main": "./src/vagueTime.js",

@@ -16,3 +16,3 @@ # vagueTime.js

### Node.js
### Via NPM

@@ -23,7 +23,10 @@ ```

### Browser
### Via Jam
To use vagueTime.js in a browser environment, you can
either clone the git repository like so:
```
jam install vague-time
```
### Via Git
```

@@ -33,8 +36,2 @@ git clone git@github.com:philbooth/vagueTime.js.git

Or use one of the growing number of package managers, such as
[Jam][jam],
[Ender][ender] (the package name for both is 'vague-time'),
[Bower][bower] ('vagueTime.js')
or [Component][component] ('philbooth/vagueTime.js').
## Usage

@@ -50,8 +47,15 @@

#### Browser
#### Via AMD
```
<script type="text/javascript" src=".../vagueTime.js/src/vagueTime.min.js"></script>
require('vague-time', function (vagueTime) {
});
```
#### Globally
```
<script src="vagueTime.min.js"></script>
```
### Calling the library

@@ -58,0 +62,0 @@

@@ -6,3 +6,3 @@ /**

/*globals exports, window */
/*globals define, module, window */

@@ -23,3 +23,3 @@ (function () {

past: 'just now',
future: 'now'
future: 'soon'
},

@@ -30,10 +30,14 @@

future: formatFuture
},
functions = {
get: getVagueTime
};
if (typeof exports === 'undefined' || exports === null) {
window.vagueTime = {
get: getVagueTime
};
if (typeof define === 'function' && define.amd) {
define([ 'vague-time' ], functions);
} else if (typeof module === 'object' && module !== null) {
module.exports = functions;
} else {
exports.get = getVagueTime;
window.vagueTime = functions;
}

@@ -40,0 +44,0 @@

@@ -1,1 +0,1 @@

(function(){"use strict";function t(t){var u,o=r(t.units),i=Date.now(),f=n(t.from,o,i),s=n(t.to,o,i),a=f-s;return a>0?u="past":(u="future",a=-a),e(a,u)}function r(t){if(t===void 0)return"ms";if("s"===t||"ms"===t)return t;throw Error("Invalid units")}function n(t,r,n){if(t===void 0)return n;if("string"==typeof t&&(t=parseInt(t,10)),"number"!=typeof t||isNaN(t))throw Error("Invalid timestamp");return"s"===r?1e3*t:t}function e(t,r){var n,e;for(n in f)if(f.hasOwnProperty(n)&&t>=f[n])return e=Math.floor(t/f[n]),a[r](e,u(n,e));return s[r]}function u(t,r){return t+(r>1?"s":"")}function o(t,r){return t+" "+r+" ago"}function i(t,r){return"in "+t+" "+r}var f={year:315576e5,month:26298e5,week:6048e5,day:864e5,hour:36e5,minute:6e4},s={past:"just now",future:"now"},a={past:o,future:i};"undefined"==typeof exports||null===exports?window.vagueTime={get:t}:exports.get=t})();
(function(){"use strict";function t(t){var r,o=e(t.units),i=Date.now(),f=n(t.from,o,i),a=n(t.to,o,i),s=f-a;return s>0?r="past":(r="future",s=-s),u(s,r)}function e(t){if(t===void 0)return"ms";if("s"===t||"ms"===t)return t;throw Error("Invalid units")}function n(t,e,n){if(t===void 0)return n;if("string"==typeof t&&(t=parseInt(t,10)),r(t)&&o(t))throw Error("Invalid time");return"number"==typeof t&&"s"===e&&(t*=1e3),t}function r(t){return"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime())}function o(t){return"number"!=typeof t||isNaN(t)}function u(t,e){var n,r;for(n in s)if(s.hasOwnProperty(n)&&t>=s[n])return r=Math.floor(t/s[n]),m[e](r,i(n,r));return c[e]}function i(t,e){return t+(e>1?"s":"")}function f(t,e){return t+" "+e+" ago"}function a(t,e){return"in "+t+" "+e}var s={year:315576e5,month:26298e5,week:6048e5,day:864e5,hour:36e5,minute:6e4},c={past:"just now",future:"soon"},m={past:f,future:a},d={get:t};"function"==typeof define&&define.amd?define(["vague-time"],d):"object"==typeof module&&null!==module?module.exports=d:window.vagueTime=d})();

@@ -282,3 +282,3 @@ /*globals require, exports */

test('get returns now when times are equal', function () {
test('get returns soon when times are equal', function () {
assert.strictEqual(vagueTime.get({

@@ -288,3 +288,3 @@ from: 1234567890,

units: 's'
}), 'now');
}), 'soon');
});

@@ -297,3 +297,3 @@

units: 's'
}), 'now');
}), 'soon');
});

@@ -323,10 +323,10 @@

test('until defaults to now', function () {
test('until defaults to soon', function () {
assert.include(vagueTime.get({
to: Date.now(),
units: 'ms'
}), 'now');
}), 'soon');
});
test('get returns now when time is 59 seconds ahead', function () {
test('get returns soon when time is 59 seconds ahead', function () {
assert.strictEqual(vagueTime.get({

@@ -336,3 +336,3 @@ from: 1234567890,

units: 's'
}), 'now');
}), 'soon');
});

@@ -348,7 +348,7 @@

test('from defaults to now', function () {
test('from defaults to soon', function () {
assert.include(vagueTime.get({
to: Date.now(),
units: 'ms'
}), 'now');
}), 'soon');
});

@@ -355,0 +355,0 @@ });

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