i18next-fs-backend
Advanced tools
Comparing version 2.0.1 to 2.1.0
@@ -57,3 +57,2 @@ "use strict"; | ||
token = lex(); | ||
parseStates[parseState](); | ||
@@ -94,3 +93,2 @@ } while (token.type !== 'eof'); | ||
c = peek(); | ||
var _token = lexStates[lexState](); | ||
@@ -149,3 +147,2 @@ if (_token) { | ||
} | ||
return lexStates[parseState](); | ||
@@ -516,5 +513,3 @@ }, | ||
return newToken('punctuator', read()); | ||
} | ||
lexState = 'value'; | ||
@@ -580,3 +575,2 @@ }, | ||
end: function end() { | ||
throw invalidChar(read()); | ||
@@ -711,3 +705,2 @@ } | ||
case 'punctuator': | ||
pop(); | ||
@@ -718,6 +711,4 @@ return; | ||
} | ||
}, | ||
afterPropertyName: function afterPropertyName() { | ||
if (token.type === 'eof') { | ||
@@ -745,3 +736,2 @@ throw invalidEOF(); | ||
afterPropertyValue: function afterPropertyValue() { | ||
if (token.type === 'eof') { | ||
@@ -757,6 +747,4 @@ throw invalidEOF(); | ||
} | ||
}, | ||
afterArrayValue: function afterArrayValue() { | ||
if (token.type === 'eof') { | ||
@@ -772,6 +760,4 @@ throw invalidEOF(); | ||
} | ||
}, | ||
end: function end() { | ||
} | ||
end: function end() {} | ||
}; | ||
@@ -797,5 +783,3 @@ function push() { | ||
break; | ||
} | ||
if (root === undefined) { | ||
@@ -840,3 +824,2 @@ root = value; | ||
} | ||
function invalidChar(c) { | ||
@@ -851,3 +834,2 @@ if (c === undefined) { | ||
} | ||
function invalidIdentifier() { | ||
@@ -854,0 +836,0 @@ column -= 5; |
@@ -10,5 +10,8 @@ "use strict"; | ||
var _writeFile2 = require("./writeFile.js"); | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var getDefaults = function getDefaults() { | ||
@@ -66,3 +69,2 @@ return { | ||
} | ||
callback(null, data); | ||
@@ -72,3 +74,2 @@ } catch (err) { | ||
} | ||
return; | ||
@@ -83,3 +84,2 @@ } | ||
} | ||
callback(null, data); | ||
@@ -104,7 +104,5 @@ }).catch(function (err) { | ||
} | ||
}, { | ||
key: "save", | ||
value: | ||
function save(language, namespace, data, callback) { | ||
value: function save(language, namespace, data, callback) { | ||
var _this3 = this; | ||
@@ -111,0 +109,0 @@ if (!callback) callback = function callback() {}; |
@@ -17,3 +17,2 @@ "use strict"; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var isDeno = typeof Deno !== 'undefined'; | ||
@@ -20,0 +19,0 @@ var YAML = typeof _yaml.default !== 'undefined' && _yaml.default.load ? _yaml.default : undefined; |
@@ -18,7 +18,5 @@ "use strict"; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var isDeno = typeof Deno !== 'undefined'; | ||
var YAML = typeof _yaml.default !== 'undefined' && _yaml.default.load ? _yaml.default : undefined; | ||
var fs = fsMod ? fsMod.default || fsMod : undefined; | ||
function dirname(path) { | ||
@@ -25,0 +23,0 @@ if (path.length === 0) return '.'; |
@@ -51,3 +51,2 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
token = lex(); | ||
parseStates[parseState](); | ||
@@ -88,3 +87,2 @@ } while (token.type !== 'eof'); | ||
c = peek(); | ||
var _token = lexStates[lexState](); | ||
@@ -143,3 +141,2 @@ if (_token) { | ||
} | ||
return lexStates[parseState](); | ||
@@ -510,5 +507,3 @@ }, | ||
return newToken('punctuator', read()); | ||
} | ||
lexState = 'value'; | ||
@@ -574,3 +569,2 @@ }, | ||
end: function end() { | ||
throw invalidChar(read()); | ||
@@ -705,3 +699,2 @@ } | ||
case 'punctuator': | ||
pop(); | ||
@@ -712,6 +705,4 @@ return; | ||
} | ||
}, | ||
afterPropertyName: function afterPropertyName() { | ||
if (token.type === 'eof') { | ||
@@ -739,3 +730,2 @@ throw invalidEOF(); | ||
afterPropertyValue: function afterPropertyValue() { | ||
if (token.type === 'eof') { | ||
@@ -751,6 +741,4 @@ throw invalidEOF(); | ||
} | ||
}, | ||
afterArrayValue: function afterArrayValue() { | ||
if (token.type === 'eof') { | ||
@@ -766,6 +754,4 @@ throw invalidEOF(); | ||
} | ||
}, | ||
end: function end() { | ||
} | ||
end: function end() {} | ||
}; | ||
@@ -791,5 +777,3 @@ function push() { | ||
break; | ||
} | ||
if (root === undefined) { | ||
@@ -834,3 +818,2 @@ root = value; | ||
} | ||
function invalidChar(c) { | ||
@@ -845,3 +828,2 @@ if (c === undefined) { | ||
} | ||
function invalidIdentifier() { | ||
@@ -848,0 +830,0 @@ column -= 5; |
@@ -0,4 +1,7 @@ | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
import { defaults, debounce, getPath, setPath, pushPath } from './utils.js'; | ||
@@ -59,3 +62,2 @@ import { readFile, readFileSync } from './readFile.js'; | ||
} | ||
callback(null, data); | ||
@@ -65,3 +67,2 @@ } catch (err) { | ||
} | ||
return; | ||
@@ -76,3 +77,2 @@ } | ||
} | ||
callback(null, data); | ||
@@ -97,7 +97,5 @@ }).catch(function (err) { | ||
} | ||
}, { | ||
key: "save", | ||
value: | ||
function save(language, namespace, data, callback) { | ||
value: function save(language, namespace, data, callback) { | ||
var _this3 = this; | ||
@@ -104,0 +102,0 @@ if (!callback) callback = function callback() {}; |
@@ -8,3 +8,2 @@ import JSON5 from './formats/json5.js'; | ||
var fs = fsMod ? fsMod.default || fsMod : undefined; | ||
function dirname(path) { | ||
@@ -11,0 +10,0 @@ if (path.length === 0) return '.'; |
@@ -11,3 +11,3 @@ import { BackendModule, ReadCallback } from "i18next"; | ||
interface BackendOptions { | ||
export interface FsBackendOptions { | ||
/** | ||
@@ -35,7 +35,7 @@ * path where resources get loaded from, or a function | ||
export default class I18NexFsBackend | ||
implements BackendModule<BackendOptions> | ||
implements BackendModule<FsBackendOptions> | ||
{ | ||
static type: "backend"; | ||
constructor(services?: any, options?: BackendOptions); | ||
init(services?: any, options?: BackendOptions): void; | ||
constructor(services?: any, options?: FsBackendOptions); | ||
init(services?: any, options?: FsBackendOptions): void; | ||
read(language: string, namespace: string, callback: ReadCallback): void; | ||
@@ -50,9 +50,3 @@ create?( | ||
services: any; | ||
options: BackendOptions; | ||
options: FsBackendOptions; | ||
} | ||
declare module "i18next" { | ||
interface CustomPluginOptions { | ||
backend?: BackendOptions; | ||
} | ||
} |
{ | ||
"name": "i18next-fs-backend", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"private": false, | ||
@@ -27,10 +27,10 @@ "type": "module", | ||
"@babel/cli": "7.19.3", | ||
"@babel/core": "7.19.6", | ||
"@babel/preset-env": "7.19.4", | ||
"@babel/core": "7.20.5", | ||
"@babel/preset-env": "7.20.2", | ||
"babel-plugin-add-module-exports": "1.0.4", | ||
"dtslint": "4.2.1", | ||
"eslint": "8.26.0", | ||
"eslint": "8.29.0", | ||
"eslint-config-standard": "17.0.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-n": "15.3.0", | ||
"eslint-plugin-n": "15.6.0", | ||
"eslint-plugin-promise": "6.1.1", | ||
@@ -40,3 +40,3 @@ "eslint-plugin-require-path-exists": "1.1.9", | ||
"expect.js": "0.3.1", | ||
"i18next": "22.0.2", | ||
"i18next": "22.1.5", | ||
"js-yaml": "4.1.0", | ||
@@ -46,4 +46,4 @@ "json5": "2.2.1", | ||
"tslint": "5.20.1", | ||
"tsd": "0.24.1", | ||
"typescript": "4.8.4", | ||
"tsd": "0.25.0", | ||
"typescript": "4.9.4", | ||
"uglify-js": "3.17.4" | ||
@@ -50,0 +50,0 @@ }, |
@@ -93,2 +93,21 @@ # Introduction | ||
## TypeScript | ||
To properly type the backend options, you can import the `FsBackendOptions` interface and use it as a generic type parameter to the i18next's `init` method, e.g.: | ||
```ts | ||
import i18n from 'i18next' | ||
import FsBackend, { FsBackendOptions } from 'i18next-fs-backend' | ||
i18n | ||
.use(FsBackend) | ||
.init<FsBackendOptions>({ | ||
backend: { | ||
// fs backend options | ||
}, | ||
// other i18next options | ||
}) | ||
``` | ||
# If set i18next initImmediate option to false it will load the files synchronously | ||
@@ -95,0 +114,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
488277
149
13766