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

javascript-time-ago

Package Overview
Dependencies
Maintainers
1
Versions
120
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

javascript-time-ago - npm Package Compare versions

Comparing version 0.2.7 to 0.2.8

2

build/classify elapsed.js

@@ -84,2 +84,4 @@ 'use strict';

// just now
// a minute ago
// 2 minutes ago
// 5 minutes ago

@@ -86,0 +88,0 @@ // 10 minutes ago

38

build/time ago.js

@@ -44,3 +44,3 @@ 'use strict';

var React_time_ago = function () {
var Javascript_time_ago = function () {

@@ -50,4 +50,4 @@ // For all configured locales

function React_time_ago(locales, options) {
(0, _classCallCheck3.default)(this, React_time_ago);
function Javascript_time_ago(locales, options) {
(0, _classCallCheck3.default)(this, Javascript_time_ago);
this.formatters = {};

@@ -104,3 +104,3 @@

(0, _createClass3.default)(React_time_ago, [{
(0, _createClass3.default)(Javascript_time_ago, [{
key: 'format',

@@ -121,10 +121,10 @@ value: function format(input) {

if (typeof input === 'number') {
if (input.constructor === Date) {
date = input;
time = input.getTime();
} else if (typeof input === 'number') {
time = input;
date = new Date(input);
} else if (input.constructor === Date) {
date = input;
time = input.getTime();
} else {
throw new Error('Unsupported fuzzy time input: ' + (typeof input === 'undefined' ? 'undefined' : (0, _typeof3.default)(input)) + ', ' + input);
throw new Error('Unsupported relative time formatter input: ' + (typeof input === 'undefined' ? 'undefined' : (0, _typeof3.default)(input)) + ', ' + input);
}

@@ -204,3 +204,3 @@

// Get relative time formatter messages for this locale
var locale_data = React_time_ago.locale_data[this.locale];
var locale_data = Javascript_time_ago.locale_data[this.locale];

@@ -243,3 +243,3 @@ // Fallback to "default" flavour if the given flavour isn't available

// for the given time interval measurement unit
var formatter_messages = React_time_ago.locale_data[this.locale][flavour][unit];
var formatter_messages = Javascript_time_ago.locale_data[this.locale][flavour][unit];

@@ -357,3 +357,3 @@ // Locale specific time interval formatter messages

}]);
return React_time_ago;
return Javascript_time_ago;
}();

@@ -366,5 +366,5 @@

React_time_ago.default_locale = 'en';
React_time_ago.locale_data = {};
exports.default = React_time_ago;
Javascript_time_ago.default_locale = 'en';
Javascript_time_ago.locale_data = {};
exports.default = Javascript_time_ago;
function resolve_locale(locales) {

@@ -377,3 +377,3 @@ // Suppose it's an array

// Create a copy of the array so we can push on the default locale.
locales = (locales || []).concat(React_time_ago.default_locale);
locales = (locales || []).concat(Javascript_time_ago.default_locale);

@@ -398,3 +398,3 @@ // Using the set of locales + the default locale, we look for the first one

if (React_time_ago.locale_data[locale_try]) {
if (Javascript_time_ago.locale_data[locale_try]) {
// Return the normalized locale string;

@@ -428,3 +428,3 @@ // e.g., we return "en-US",

// Adds locale data
React_time_ago.locale = function (locale, locale_data) {
Javascript_time_ago.locale = function (locale, locale_data) {
var locale_data_map = {};

@@ -466,3 +466,3 @@

// Store locale specific messages in the static variable
React_time_ago.locale_data[locale.toLowerCase()] = locale_data_map;
Javascript_time_ago.locale_data[locale.toLowerCase()] = locale_data_map;

@@ -469,0 +469,0 @@ // (will be added manually by this library user)

{
"name": "javascript-time-ago",
"version": "0.2.7",
"version": "0.2.8",
"description": "International highly customizable relative time formatting",

@@ -5,0 +5,0 @@ "main": "index.umd.js",

@@ -50,5 +50,10 @@ # javascript-time-ago

// Import locale specific relative date/time messages
import english from 'javascript-time-ago/locales/en'
import russian from 'javascript-time-ago/locales/ru'
// Load locale specific relative date/time messages
//
// (this is only needed in client-side code;
// server-side instance will load all
// supported locales automatically at startup)
//
javascript_time_ago.locale('en', require('javascript-time-ago/locales/en'))
javascript_time_ago.locale('ru', require('javascript-time-ago/locales/ru'))

@@ -61,2 +66,6 @@ // Load number pluralization functions for the locales.

//
// (this is only needed in client-side code;
// server-side instance will load all
// supported locales automatically at startup)
//
global.IntlMessageFormat = require('intl-messageformat')

@@ -66,7 +75,4 @@ require('intl-messageformat/dist/locale-data/en')

// Add the imported locale specific relative date/time messages
javascript_time_ago.locale('en', english)
javascript_time_ago.locale('ru', russian)
// Initialization complete.
// Client-side initialization complete.
// (no server-side initialization is required)
// Ready to format relative dates and times.

@@ -109,10 +115,2 @@

import javascript_time_ago from 'javascript-time-ago'
// Import locale specific relative date/time messages
import english from 'javascript-time-ago/locales/en'
// Add the imported locale specific relative date/time messages
javascript_time_ago.locale('en', english)
const time_ago = new javascript_time_ago('en-US')

@@ -143,2 +141,4 @@

* just now
* a minute
* 2 minutes
* 5 minutes

@@ -286,3 +286,3 @@ * 10 minutes

* `style` – a preferred formatting style (e.g. `tiny`, `short`, `long`)
* `flavour` – preferred labels style (e.g. `tiny`, `short`, `long`)
* `units` – a list of time interval measurement units which can be used in the formatted output (e.g. `['second', 'minute', 'hour']`)

@@ -331,2 +331,6 @@ * `gradation` – custom time interval measurement units gradation

## React
There is also a [React component](https://github.com/halt-hammerzeit/react-time-ago).
## Contributing

@@ -333,0 +337,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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