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

intl-relativeformat

Package Overview
Dependencies
Maintainers
4
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intl-relativeformat - npm Package Compare versions

Comparing version 6.2.2 to 6.3.0

.DS_Store

123

CHANGELOG.md

@@ -6,10 +6,13 @@ # Change Log

## [6.2.2](https://github.com/formatjs/formatjs/compare/intl-relativeformat@6.2.1...intl-relativeformat@6.2.2) (2019-06-18)
# [6.3.0](https://github.com/formatjs/formatjs/compare/intl-relativeformat@6.2.2...intl-relativeformat@6.3.0) (2019-06-27)
**Note:** Version bump only for package intl-relativeformat
### Features
- **intl-relativetimeformat:** make intl-relativetimeformat test262-compliant ([#95](https://github.com/formatjs/formatjs/issues/95)) ([91669a3](https://github.com/formatjs/formatjs/commit/91669a3))
- **intl-utils:** Add intl-utils ([#98](https://github.com/formatjs/formatjs/issues/98)) ([2329c57](https://github.com/formatjs/formatjs/commit/2329c57))
## [6.2.2](https://github.com/formatjs/formatjs/compare/intl-relativeformat@6.2.1...intl-relativeformat@6.2.2) (2019-06-18)
**Note:** Version bump only for package intl-relativeformat
## [6.2.1](https://github.com/formatjs/formatjs/compare/intl-relativeformat@6.2.0...intl-relativeformat@6.2.1) (2019-06-18)

@@ -19,17 +22,8 @@

# [6.2.0](https://github.com/formatjs/formatjs/compare/intl-relativeformat@6.1.1...intl-relativeformat@6.2.0) (2019-06-18)
### Features
* **intl-format-cache:** fix TS definition ([71ae9eb](https://github.com/formatjs/formatjs/commit/71ae9eb))
- **intl-format-cache:** fix TS definition ([71ae9eb](https://github.com/formatjs/formatjs/commit/71ae9eb))
## [6.1.1](https://github.com/formatjs/formatjs/compare/intl-relativeformat@6.1.0...intl-relativeformat@6.1.1) (2019-06-12)

@@ -39,93 +33,63 @@

# [6.1.0](https://github.com/formatjs/formatjs/compare/intl-relativeformat@6.0.0...intl-relativeformat@6.1.0) (2019-06-05)
### Features
* **intl-relativetimeformat:** rename due to npm squatting ([b4476e0](https://github.com/formatjs/formatjs/commit/b4476e0))
- **intl-relativetimeformat:** rename due to npm squatting ([b4476e0](https://github.com/formatjs/formatjs/commit/b4476e0))
# [6.0.0](https://github.com/formatjs/formatjs/compare/intl-relativeformat@5.0.0...intl-relativeformat@6.0.0) (2019-06-05)
### Features
* add package intl-relativetimeformat ([#51](https://github.com/formatjs/formatjs/issues/51)) ([48c0f43](https://github.com/formatjs/formatjs/commit/48c0f43))
* **intl-relativeformat:** rm rolluped dist ([c6f94e4](https://github.com/formatjs/formatjs/commit/c6f94e4))
* **intl-relativeformat:** Use Intl.RelativeTimeFormat ([c014ce0](https://github.com/formatjs/formatjs/commit/c014ce0))
- add package intl-relativetimeformat ([#51](https://github.com/formatjs/formatjs/issues/51)) ([48c0f43](https://github.com/formatjs/formatjs/commit/48c0f43))
- **intl-relativeformat:** rm rolluped dist ([c6f94e4](https://github.com/formatjs/formatjs/commit/c6f94e4))
- **intl-relativeformat:** Use Intl.RelativeTimeFormat ([c014ce0](https://github.com/formatjs/formatjs/commit/c014ce0))
### BREAKING CHANGES
* **intl-relativeformat:** This changes the list of assets we package. However,
entry point is still intact.
* **intl-relativeformat:** We now use Intl.RelativeTimeFormat in
intl-relativeformat so consuming env should polyfill this accordingly
- **intl-relativeformat:** This changes the list of assets we package. However,
entry point is still intact.
- **intl-relativeformat:** We now use Intl.RelativeTimeFormat in
intl-relativeformat so consuming env should polyfill this accordingly
# [5.0.0](https://github.com/formatjs/formatjs/compare/intl-relativeformat@3.1.0...intl-relativeformat@5.0.0) (2019-06-03)
### Features
* **formatjs-extract-cldr-data:** add quarter data ([#53](https://github.com/formatjs/formatjs/issues/53)) ([e37a242](https://github.com/formatjs/formatjs/commit/e37a242))
* **formatjs-extract-cldr-data:** rm plural ([#52](https://github.com/formatjs/formatjs/issues/52)) ([62a6de4](https://github.com/formatjs/formatjs/commit/62a6de4))
* **intl-messageformat:** Add `getAst` method ([3d6c289](https://github.com/formatjs/formatjs/commit/3d6c289))
- **formatjs-extract-cldr-data:** add quarter data ([#53](https://github.com/formatjs/formatjs/issues/53)) ([e37a242](https://github.com/formatjs/formatjs/commit/e37a242))
- **formatjs-extract-cldr-data:** rm plural ([#52](https://github.com/formatjs/formatjs/issues/52)) ([62a6de4](https://github.com/formatjs/formatjs/commit/62a6de4))
- **intl-messageformat:** Add `getAst` method ([3d6c289](https://github.com/formatjs/formatjs/commit/3d6c289))
### BREAKING CHANGES
* **formatjs-extract-cldr-data:** Remove plural extraction since we rely on native
Intl.PluralRules
- Upgrade CLDR to v35
- Extract `*-narrow` rules for relative fields
- Remove es-AR since as of CLDRv35 it cannot be de-duped
- **formatjs-extract-cldr-data:** Remove plural extraction since we rely on native
Intl.PluralRules
* Upgrade CLDR to v35
* Extract `*-narrow` rules for relative fields
* Remove es-AR since as of CLDRv35 it cannot be de-duped
# [4.0.0](https://github.com/formatjs/formatjs/compare/intl-relativeformat@3.1.0...intl-relativeformat@4.0.0) (2019-06-03)
### Features
* **formatjs-extract-cldr-data:** add quarter data ([#53](https://github.com/formatjs/formatjs/issues/53)) ([e37a242](https://github.com/formatjs/formatjs/commit/e37a242))
* **formatjs-extract-cldr-data:** rm plural ([#52](https://github.com/formatjs/formatjs/issues/52)) ([62a6de4](https://github.com/formatjs/formatjs/commit/62a6de4))
* **intl-messageformat:** Add `getAst` method ([3d6c289](https://github.com/formatjs/formatjs/commit/3d6c289))
- **formatjs-extract-cldr-data:** add quarter data ([#53](https://github.com/formatjs/formatjs/issues/53)) ([e37a242](https://github.com/formatjs/formatjs/commit/e37a242))
- **formatjs-extract-cldr-data:** rm plural ([#52](https://github.com/formatjs/formatjs/issues/52)) ([62a6de4](https://github.com/formatjs/formatjs/commit/62a6de4))
- **intl-messageformat:** Add `getAst` method ([3d6c289](https://github.com/formatjs/formatjs/commit/3d6c289))
### BREAKING CHANGES
* **formatjs-extract-cldr-data:** Remove plural extraction since we rely on native
Intl.PluralRules
- Upgrade CLDR to v35
- Extract `*-narrow` rules for relative fields
- Remove es-AR since as of CLDRv35 it cannot be de-duped
- **formatjs-extract-cldr-data:** Remove plural extraction since we rely on native
Intl.PluralRules
* Upgrade CLDR to v35
* Extract `*-narrow` rules for relative fields
* Remove es-AR since as of CLDRv35 it cannot be de-duped
# [3.1.0](https://github.com/formatjs/formatjs/compare/intl-relativeformat@3.0.1...intl-relativeformat@3.1.0) (2019-05-31)
### Features
* **intl-relativeformat:** expose es6 entry point in package.json ([baf36b5](https://github.com/formatjs/formatjs/commit/baf36b5))
- **intl-relativeformat:** expose es6 entry point in package.json ([baf36b5](https://github.com/formatjs/formatjs/commit/baf36b5))
## [3.0.1](https://github.com/formatjs/formatjs/compare/intl-relativeformat@2.2.0...intl-relativeformat@3.0.1) (2019-05-31)

@@ -135,17 +99,8 @@

# [2.2.0](https://github.com/yahoo/intl-relativeformat/compare/intl-relativeformat@2.1.3...intl-relativeformat@2.2.0) (2019-05-29)
### Features
* **intl-relativeformat:** Improve day diffing ([#45](https://github.com/yahoo/intl-relativeformat/issues/45)) ([8f2c649](https://github.com/yahoo/intl-relativeformat/commit/8f2c649))
- **intl-relativeformat:** Improve day diffing ([#45](https://github.com/yahoo/intl-relativeformat/issues/45)) ([8f2c649](https://github.com/yahoo/intl-relativeformat/commit/8f2c649))
## [2.1.3](https://github.com/yahoo/intl-relativeformat/compare/intl-relativeformat@2.1.1...intl-relativeformat@2.1.3) (2019-05-28)

@@ -155,6 +110,2 @@

## [2.1.2](https://github.com/yahoo/intl-relativeformat/compare/intl-relativeformat@2.1.1...intl-relativeformat@2.1.2) (2019-05-28)

@@ -164,6 +115,2 @@

## 2.1.1 (2019-05-28)

@@ -173,6 +120,2 @@

# 2.1.0 (2019-05-28)

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

import { IntlRelativeTimeFormat } from '@formatjs/intl-relativetimeformat';
import { default as IntlRelativeTimeFormat } from '@formatjs/intl-relativetimeformat';
import { SUPPORTED_FIELD, STYLE, LocaleData } from './types';
declare global {
namespace Intl {
var RelativeTimeFormat: IntlRelativeTimeFormat;
var RelativeTimeFormat: typeof IntlRelativeTimeFormat;
}

@@ -7,0 +7,0 @@ }

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

import { IntlRelativeTimeFormat } from '@formatjs/intl-relativetimeformat';
import { default as IntlRelativeTimeFormat } from '@formatjs/intl-relativetimeformat';
import { SUPPORTED_FIELD, STYLE, LocaleData } from './types';
declare global {
namespace Intl {
var RelativeTimeFormat: IntlRelativeTimeFormat;
var RelativeTimeFormat: typeof IntlRelativeTimeFormat;
}

@@ -7,0 +7,0 @@ }

{
"name": "intl-relativeformat",
"version": "6.2.2",
"version": "6.3.0",
"description": "Formats JavaScript dates to relative time strings.",

@@ -29,3 +29,3 @@ "keywords": [

"devDependencies": {
"@formatjs/intl-relativetimeformat": "^2.0.2"
"@formatjs/intl-relativetimeformat": "^2.1.0"
},

@@ -39,3 +39,4 @@ "scripts": {

"license": "BSD-3-Clause",
"gitHead": "1dc8b1c43fd0704398dffd888d70214558cfb17d"
"deprecated": true,
"gitHead": "8b0baec8eda5002715cf893274fe59782fc2d371"
}

@@ -1,4 +0,99 @@

Intl RelativeFormat
===================
# THIS PACKAGE HAS BEEN DEPRECATED
# Migration Guide
This package has deviated from the [`Intl.RelativeTimeFormat` spec](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat) rather heavily. Therefore, we've deprecated this package and add [`@formatjs/intl-relativetimeformat](https://www.npmjs.com/package/@formatjs/intl-relativetimeformat) as the spec-compliant polyfill.
1. All `units` (such as `day-short`) should be migrated similarly to:
```ts
new IntlRelativeFormat('en', { units: 'second-short' }).format(
Date.now() - 1000
);
// will be
new Intl.RelativeTimeFormat('en', { style: 'short' }).format(-1, 'second');
new IntlRelativeFormat('en', { units: 'day-narrow' }).format(
Date.now() - 48 * 3600 * 1000
);
// will be
new Intl.RelativeTimeFormat('en', { style: 'narrow' }).format(-2, 'day');
```
2. `style: numeric` will become `numeric: always` per spec (which is also the default)
```ts
new IntlRelativeFormat('en', {
units: 'second-short',
style: 'numeric'
}).format(Date.now() - 1000);
// will be
new Intl.RelativeTimeFormat('en', { style: 'short' }).format(-1, 'second');
```
```ts
new IntlRelativeFormat('en', { units: 'day-narrow', style: 'numeric' }).format(
Date.now() - 48 * 3600 * 1000
);
// will be
new Intl.RelativeTimeFormat('en', { style: 'narrow' }).format(-2, 'day');
```
3. `style: 'best fit'` is a little trickier but we have released `@formatjs/intl-utils` to ease the transition:
```ts
new IntlRelativeFormat('en', { style: 'best fit' }).format(Date.now() - 1000);
// will be
import { selectUnit } from '@formatjs/intl-utils';
const diff = selectUnit(Date.now() - 1000);
new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(
diff.value,
diff.unit
);
```
```ts
new IntlRelativeFormat('en', { style: 'best fit' }).format(
Date.now() - 48 * 3600 * 1000
);
// will be
import { selectUnit } from '@formatjs/intl-utils';
const diff = selectUnit(Date.now() - 48 * 3600 * 1000);
new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(
diff.value,
diff.unit
);
```
4. If you were using `options.now` in `format`, you can use `formatjs/intl-utils` to transition as well
```ts
new IntlRelativeFormat('en', { style: 'best fit' }).format(Date.now() - 1000, {
now: Date.now() + 1000
});
// will be
import { selectUnit } from '@formatjs/intl-utils';
const diff = selectUnit(Date.now() - 1000, Date.now() + 1000);
new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(
diff.value,
diff.unit
);
```
```ts
new IntlRelativeFormat('en', { style: 'best fit' }).format(
Date.now() - 48 * 3600 * 1000,
{ now: Date.now() + 1000 }
);
// will be
import { selectUnit } from '@formatjs/intl-utils';
const diff = selectUnit(Date.now() - 48 * 3600 * 1000, Date.now() + 1000);
new Intl.RelativeTimeFormat('en', { numeric: 'auto' }).format(
diff.value,
diff.unit
);
```
# Intl RelativeFormat
Formats JavaScript dates to relative time strings (e.g., "3 hours ago").

@@ -8,6 +103,4 @@

## Overview
Overview
--------
### Goals

@@ -39,16 +132,16 @@

var posts = [
{
id : 1,
title: 'Some Blog Post',
date : new Date(1426271670524)
},
{
id : 2,
title: 'Another Blog Post',
date : new Date(1426278870524)
}
{
id: 1,
title: 'Some Blog Post',
date: new Date(1426271670524)
},
{
id: 2,
title: 'Another Blog Post',
date: new Date(1426278870524)
}
];
posts.forEach(function (post) {
console.log(rf.format(post.date));
posts.forEach(function(post) {
console.log(rf.format(post.date));
});

@@ -61,16 +154,14 @@ // => "3 hours ago"

* Style options for `"best fit"` ("yesterday") and `"numeric"` ("1 day ago") output based on thresholds.
- Style options for `"best fit"` ("yesterday") and `"numeric"` ("1 day ago") output based on thresholds.
* Units options for always rendering in a particular unit; e.g. "30 days ago", instead of "1 month ago".
- Units options for always rendering in a particular unit; e.g. "30 days ago", instead of "1 month ago".
* Ability to specify the "now" value from which the relative time is calculated, allowing `format()`.
- Ability to specify the "now" value from which the relative time is calculated, allowing `format()`.
* Format output in relative time strings using [`Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)
- Format output in relative time strings using [`Intl.RelativeTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RelativeTimeFormat)
* Optimized for repeated calls to an `IntlRelativeFormat` instance's `format()` method.
- Optimized for repeated calls to an `IntlRelativeFormat` instance's `format()` method.
## Usage
Usage
-----
### `Intl` Dependency

@@ -126,6 +217,6 @@

- **locales** - _{String | String[]}_ - A string with a BCP 47 language tag, or an array of such strings. If you do not provide a locale, the default locale will be used. When an array of locales is provided, each item and its ancestor locales are checked and the first one with registered locale data is returned. **See: [Locale Resolution](#locale-resolution) for more details.**
- **locales** - _{String | String[]}_ - A string with a BCP 47 language tag, or an array of such strings. If you do not provide a locale, the default locale will be used. When an array of locales is provided, each item and its ancestor locales are checked and the first one with registered locale data is returned. **See: [Locale Resolution](#locale-resolution) for more details.**
- **[options]** - _{Object}_ - Optional object with user defined options for format styles.
**See: [Custom Options](#custom-options) for more details.**
- **[options]** - _{Object}_ - Optional object with user defined options for format styles.
**See: [Custom Options](#custom-options) for more details.**

@@ -140,14 +231,14 @@ _Note: The `rf` instance should be enough for your entire application, unless you want to use custom options._

* If no extra locale data is loaded, the locale will _always_ resolved to `"en"`.
- If no extra locale data is loaded, the locale will _always_ resolved to `"en"`.
* If locale data is missing for a leaf locale like `"fr-FR"`, but there _is_ data for one of its ancestors, `"fr"` in this case, then its ancestor will be used.
- If locale data is missing for a leaf locale like `"fr-FR"`, but there _is_ data for one of its ancestors, `"fr"` in this case, then its ancestor will be used.
* If there's data for the specified locale, then that locale will be resolved; i.e.,
- If there's data for the specified locale, then that locale will be resolved; i.e.,
```js
var rf = new IntlRelativeFormat('en-US');
assert(rf.resolvedOptions().locale === 'en-US'); // true
```
```js
var rf = new IntlRelativeFormat('en-US');
assert(rf.resolvedOptions().locale === 'en-US'); // true
```
* The resolved locales are now normalized; e.g., `"en-us"` will resolve to: `"en-US"`.
- The resolved locales are now normalized; e.g., `"en-us"` will resolve to: `"en-US"`.

@@ -166,3 +257,3 @@ _Note: When an array is provided for `locales`, the above steps happen for each item in that array until a match is found._

var rf = new IntlRelativeFormat('en', {
units: 'day'
units: 'day'
});

@@ -180,3 +271,3 @@ var output = rf.format(dateValue);

var rf = new IntlRelativeFormat('en', {
style: 'numeric'
style: 'numeric'
});

@@ -210,25 +301,22 @@ var output = rf.format(dateValue);

## License
License
-------
This software is free to use under the Yahoo! Inc. BSD license.
See the [LICENSE file][LICENSE] for license text and copyright information.
See the [LICENSE file][license] for license text and copyright information.
[npm]: https://www.npmjs.org/package/intl-relativeformat
[npm-badge]: https://img.shields.io/npm/v/intl-relativeformat.svg?style=flat-square
[parser]: https://github.com/formatjs/formatjs
[CLDR]: http://cldr.unicode.org/
[Intl]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
[Intl-NF]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
[Intl-DTF]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
[Intl-Node]: https://github.com/joyent/node/issues/6371
[Intl.js]: https://github.com/andyearnshaw/Intl.js
[cldr]: http://cldr.unicode.org/
[intl]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
[intl-nf]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
[intl-dtf]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
[intl-node]: https://github.com/joyent/node/issues/6371
[intl.js]: https://github.com/andyearnshaw/Intl.js
[rawgit]: https://rawgit.com/
[semver]: http://semver.org/
[LICENSE]: https://github.com/formatjs/formatjs/blob/master/LICENSE
[license]: https://github.com/formatjs/formatjs/blob/master/LICENSE
[moment.js]: http://momentjs.com/
[ECMA 402]: http://www.ecma-international.org/ecma-402/1.0/index.html
[DateTimeFormat]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
[NumberFormat]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat
[ecma 402]: http://www.ecma-international.org/ecma-402/1.0/index.html
[datetimeformat]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat
[numberformat]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat

@@ -10,3 +10,3 @@ /*

import {
IntlRelativeTimeFormat,
default as IntlRelativeTimeFormat,
FormattableUnit

@@ -18,3 +18,3 @@ } from '@formatjs/intl-relativetimeformat';

namespace Intl {
var RelativeTimeFormat: IntlRelativeTimeFormat;
var RelativeTimeFormat: typeof IntlRelativeTimeFormat;
}

@@ -21,0 +21,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