File tree Expand file tree Collapse file tree 4 files changed +17
-5
lines changed
Expand file tree Collapse file tree 4 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -5,4 +5,5 @@ const y18n = (opts) => {
55 return _y18n ( opts , shim )
66}
77
8+ export { Y18N } from './build/lib/index.js'
89export default y18n
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ export interface PlatformShim {
3030}
3131
3232let shim : PlatformShim
33- class Y18N {
33+ export class Y18N {
3434 directory : string ;
3535 updateFiles : boolean ;
3636 locale : string ;
@@ -189,7 +189,7 @@ class Y18N {
189189 if ( shim . fs . readFileSync ) {
190190 localeLookup = JSON . parse ( shim . fs . readFileSync ( languageFile , 'utf-8' ) )
191191 }
192- } catch ( err ) {
192+ } catch ( err : any ) {
193193 if ( err instanceof SyntaxError ) {
194194 err . message = 'syntax error in ' + languageFile
195195 }
Original file line number Diff line number Diff line change 4141 "prepare" : " npm run compile"
4242 },
4343 "devDependencies" : {
44- "@types/node" : " ^14.6.4 " ,
44+ "@types/node" : " ^16.11.7 " ,
4545 "@wessberg/rollup-plugin-ts" : " ^1.3.1" ,
4646 "c8" : " ^7.3.0" ,
4747 "chai" : " ^4.0.1" ,
Original file line number Diff line number Diff line change 11/* global describe, it */
22
33import * as assert from 'assert'
4- import y18n from '../../index.mjs'
4+ import y18n , { Y18N } from '../../index.mjs'
55
66describe ( 'y18n' , function ( ) {
77 it ( '__ smoke test' , function ( ) {
88 const __ = y18n ( {
99 locale : 'pirate' ,
1010 directory : './test/locales'
1111 } ) . __
12-
1312 assert . strictEqual (
1413 __ `Hi, ${ 'Ben' } ${ 'Coe' } !` ,
1514 'Yarr! Shiver me timbers, why \'tis Ben Coe!'
1615 )
1716 } )
17+
18+ it ( 'explicit construction' , ( ) => {
19+ const y18nOpts = {
20+ locale : 'pirate' ,
21+ directory : './test/locales'
22+ }
23+ const _y18n = new Y18N ( y18nOpts )
24+ assert . strictEqual (
25+ _y18n . __ `Hi, ${ 'Ben' } ${ 'Coe' } !` ,
26+ 'Yarr! Shiver me timbers, why \'tis Ben Coe!'
27+ )
28+ } )
1829} )
You can’t perform that action at this time.
0 commit comments