Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
Retarget es5
Browse files Browse the repository at this point in the history
Previously changed in #24
  • Loading branch information
eps1lon committed Mar 10, 2018
1 parent dd78f2f commit e7edf89
Show file tree
Hide file tree
Showing 4 changed files with 1,129 additions and 152 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased](https://github.com/eps1lon/poe-i18n/compare/v0.8.0...HEAD)
### Breaking
- ES module build now targets ES6. (#24)

### Added
- `groupMods()` to generate a fitting translation for a collection of mods
(e.g. mods of a `correct_group`) (#30)
Expand Down
168 changes: 151 additions & 17 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
declare module "translate/match" {
export type Boundary = number | '#';
export type BoundedRange = [Boundary, Boundary];
export type Value = Boundary | BoundedRange;
export enum Match {
exact = 0,
subset = 1,
superset = 2,
partial_upper = 3,
partial_lower = 4,
none = 5,
}
export function matchesSingle(value: Value, matcher: Value): Match;
export function matches(values: Value[], matchers: Value[]): Match[];
}
declare module "types/StatDescription" {
export interface Descriptions {
[key: string]: Description;
Expand Down Expand Up @@ -58,14 +43,41 @@ declare module "types/StatDescription" {
export type Value = AnyValue | number;
export type AnyValue = '#';
}
declare module "translate/match" {
import { Translation } from "types/StatDescription";
export type Boundary = number | '#';
export type BoundedRange = [Boundary, Boundary];
export type Value = Boundary | BoundedRange;
export enum Match {
exact = 0,
subset = 1,
superset = 2,
partial_upper = 3,
partial_lower = 4,
none = 5,
}
export function matchesTranslation(translation: Translation, values: Value[]): boolean;
export function matchesSingle(value: Value, matcher: Value): Match;
export function matches(values: Value[], matchers: Value[]): Match[];
}
declare module "types/StatValue" {
export type StatValue = number | Range;
export type Range = [number, number];
export const isRange: (value: StatValue) => value is [number, number];
export const isZero: (value: StatValue) => boolean;
}
declare module "localize/formatters" {
import { StatValue } from "types/StatValue";
export type Formatter = (value: number) => number | string;
export const item_classes: string[];
export const formatters: {
[key: string]: Formatter;
};
export const inverse_formatters: {
[key: string]: (s: string) => number;
};
export function inverseFactory(formatter_id: string): (s: string) => number;
export function regexpFactory(formatter_id: string): string;
export default function factory(formatter_id: string): (value: StatValue) => string;
}
declare module "localize/formatValues" {
Expand All @@ -83,27 +95,75 @@ declare module "translate/printf" {
export type Params = Array<number | [number, number]>;
export default function printf(text: string, params: Params, formatters?: Formatter[]): string;
}
declare module "format/stats" {
import { StatLocaleDatas } from "types/StatDescription";
declare module "translate/translate" {
import { Description, Translation } from "types/StatDescription";
export type Stat = {
id: string;
value: number | [number, number];
alias?: string;
};
export const NO_DESCRIPTION = "NO_DESCRIPTION";
export default function translate(description: Description, provided: Map<string, Stat>,
/**
* @param t
* @param count {number} number of params
*/
getFormatters?: (t: Translation, count: number) => Translation['formatters']): string | undefined;
}
declare module "util/NamedGroupsRegexp" {
export default class NamedGroupsRegexp {
private regexp;
private groups;
constructor(regexp: RegExp, groups: string[]);
match(text: string): {
[key: string]: string;
} | null;
toString(): RegExp;
}
}
declare module "translate/asRegexp" {
import { Translation } from "types/StatDescription";
import NamedGroupsRegexp from "util/NamedGroupsRegexp";
export default function asRegexp(translation: Translation): NamedGroupsRegexp;
}
declare module "translate/index" {
import translate from "translate/translate";
export default translate;
export { default as asRegexp } from "translate/asRegexp";
export { matchesTranslation } from "translate/match";
export { NO_DESCRIPTION, Stat } from "translate/translate";
}
declare module "format/stats" {
import { Stat } from "translate/index";
import { Description, Descriptions, StatLocaleDatas, Translation } from "types/StatDescription";
export { Stat } from "translate/index";
export type Options = {
datas: StatLocaleDatas;
fallback: Fallback | FallbackCallback;
start_file: string;
getFormatters: (t: Translation, stat: Stat, n: number) => Translation['formatters'];
};
export type TranslatedStats = string[];
export type FallbackCallback = (id: string, stat: Stat) => string | null;
export class NoDescriptionFound extends Error {
constructor(stats: Stat[]);
}
export enum Fallback {
throw = 0,
id = 1,
skip = 2,
skip_if_zero = 3,
}
const formatStats: (stats: Stat[], options?: Partial<Options>) => string[];
export default formatStats;
/**
* creates an array of methods that can be used to find a description for a
* given stat.
*
* return value is to be interpreted as a priority queue
* @param descriptions
*/
export function createDescriptionFindStrategies(descriptions: Descriptions): Array<(stat: Stat) => Description | undefined>;
}
declare module "translate/descriptions_dependency" {
const _default: Readonly<{
Expand Down Expand Up @@ -137,9 +197,79 @@ declare module "format/gemStats" {
export default function formatGemStats(gem_id: GemId, stats: Stat[], options?: Partial<Options>): string[];
export function requiredLocaleDatas(gem_id: GemId): string[];
}
declare module "format/groupMods" {
import { Options as FormatStatsOptions, Stat } from "format/stats";
export { Stat } from "format/stats";
export type Options = {
resolveWordConflict: (words: string[]) => string;
} & FormatStatsOptions;
/**
* tries to find a string that describes the given mods
*
* given a list of mods where a mod consists of at least one stat
* get a translation t of that mod and consider it a row
* split t into words and consider every word as a column
* collapse the table into a single row
* columns with different words get resolved by a given strategy
*
*
*
* Adds # to Fire Gems
* Adds # to Cold Gems
* ----
* Adds # to * Gems
*
* @param mods
* @param options
*/
export default function groupMod(mods: Stat[][], options?: Partial<Options>): string;
}
declare module "util/symbolicStats" {
import { Stat } from "format/stats";
import { Description, Matcher } from "types/StatDescription";
export function deterministicValueForMatcher(matcher: Matcher): number;
export function buildRandomStats(description: Description): Stat[][] | null;
}
declare module "format/util" {
import { Descriptions, StatLocaleDatas } from "types/StatDescription";
export function getDescriptions(datas: StatLocaleDatas, start_file: string): IterableIterator<Descriptions>;
}
declare module "format/textToStats" {
import { Stat } from "translate/index";
import { StatLocaleDatas } from "types/StatDescription";
export type Options = {
datas: StatLocaleDatas;
start_file: string;
};
/**
* finds every stat or list of stats that could produce this text with its values
*
* use {textToStatsSingle} if you just want the first match
* use {textToStatsArray} if you want the generator values as an array
*
* @param text the stat text
* @param options see type definition
*/
export default function textToStats(text: string, options?: Partial<Options>): IterableIterator<Stat[]>;
/**
* @see {textToStats} as array
*
* @param text
* @param options
*/
export function textToStatsArray(text: string, options?: Partial<Options>): Stat[][];
/**
* only first match of @see {textToStats} but throws if none was found
*
* @param text
* @param options
*/
export function textToStatsFirst(text: string, options?: Partial<Options>): Stat[];
}
declare module "Format" {
import { GemId } from "format/gemStats";
import { Stat } from "format/stats";
import { Options as TextToStatsOptions } from "format/textToStats";
import { StatLocaleDatas } from "types/StatDescription";
export enum Fallback {
throw = 0,
Expand All @@ -156,6 +286,8 @@ declare module "Format" {
configure(options: Partial<Options>): void;
stats(stats: Stat[]): string[];
gemStats(gem_id: GemId, stats: Stat[]): string[];
groupMods(mods: Stat[][]): string;
textToStats(text: string, options?: Partial<TextToStatsOptions>): IterableIterator<Stat[]>;
}
const _default: Format;
export default _default;
Expand All @@ -172,6 +304,8 @@ declare module "util/inflectionIdentifier" {
declare module "index" {
export { default as formatStats, Fallback } from "format/stats";
export { default as formatGemStats } from "format/gemStats";
export { default as groupMods } from "format/groupMods";
export { default as textToStats, textToStatsArray, textToStatsFirst } from "format/textToStats";
export { default as format, Format } from "Format";
export { default as requiredLocaleDatas } from "requiredLocaleDatas";
export { default as formatValueRange } from "localize/formatValueRange";
Expand Down
Loading

0 comments on commit e7edf89

Please sign in to comment.