@i18n-micro/core 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,103 +0,0 @@
1
- import {
2
- interpolate,
3
- isNoPrefixStrategy,
4
- isPrefixAndDefaultStrategy,
5
- isPrefixExceptDefaultStrategy,
6
- isPrefixStrategy,
7
- withPrefixStrategy,
8
- } from '../src/helpers'
9
-
10
- describe('Helpers', () => {
11
- describe('interpolate', () => {
12
- test('should replace placeholders with params', () => {
13
- const template = 'Hello, {name}! Your age is {age}.'
14
- const params = { name: 'John', age: 30 }
15
- const result = interpolate(template, params)
16
- expect(result).toBe('Hello, John! Your age is 30.')
17
- })
18
-
19
- test('should handle missing params by leaving placeholders', () => {
20
- const template = 'Hello, {name}! Your age is {age}.'
21
- const params = { name: 'John' } // age is missing
22
- const result = interpolate(template, params)
23
- expect(result).toBe('Hello, John! Your age is {age}.')
24
- })
25
-
26
- test('should handle empty params', () => {
27
- const template = 'Hello, {name}!'
28
- const params = {}
29
- const result = interpolate(template, params)
30
- expect(result).toBe('Hello, {name}!')
31
- })
32
-
33
- test('should handle empty template', () => {
34
- const template = ''
35
- const params = { name: 'John' }
36
- const result = interpolate(template, params)
37
- expect(result).toBe('')
38
- })
39
- })
40
-
41
- describe('withPrefixStrategy', () => {
42
- test('should return true for "prefix" strategy', () => {
43
- expect(withPrefixStrategy('prefix')).toBe(true)
44
- })
45
-
46
- test('should return true for "prefix_and_default" strategy', () => {
47
- expect(withPrefixStrategy('prefix_and_default')).toBe(true)
48
- })
49
-
50
- test('should return false for other strategies', () => {
51
- expect(withPrefixStrategy('no_prefix')).toBe(false)
52
- expect(withPrefixStrategy('prefix_except_default')).toBe(false)
53
- })
54
- })
55
-
56
- describe('isNoPrefixStrategy', () => {
57
- test('should return true for "no_prefix" strategy', () => {
58
- expect(isNoPrefixStrategy('no_prefix')).toBe(true)
59
- })
60
-
61
- test('should return false for other strategies', () => {
62
- expect(isNoPrefixStrategy('prefix')).toBe(false)
63
- expect(isNoPrefixStrategy('prefix_and_default')).toBe(false)
64
- expect(isNoPrefixStrategy('prefix_except_default')).toBe(false)
65
- })
66
- })
67
-
68
- describe('isPrefixStrategy', () => {
69
- test('should return true for "prefix" strategy', () => {
70
- expect(isPrefixStrategy('prefix')).toBe(true)
71
- })
72
-
73
- test('should return false for other strategies', () => {
74
- expect(isPrefixStrategy('no_prefix')).toBe(false)
75
- expect(isPrefixStrategy('prefix_and_default')).toBe(false)
76
- expect(isPrefixStrategy('prefix_except_default')).toBe(false)
77
- })
78
- })
79
-
80
- describe('isPrefixExceptDefaultStrategy', () => {
81
- test('should return true for "prefix_except_default" strategy', () => {
82
- expect(isPrefixExceptDefaultStrategy('prefix_except_default')).toBe(true)
83
- })
84
-
85
- test('should return false for other strategies', () => {
86
- expect(isPrefixExceptDefaultStrategy('no_prefix')).toBe(false)
87
- expect(isPrefixExceptDefaultStrategy('prefix')).toBe(false)
88
- expect(isPrefixExceptDefaultStrategy('prefix_and_default')).toBe(false)
89
- })
90
- })
91
-
92
- describe('isPrefixAndDefaultStrategy', () => {
93
- test('should return true for "prefix_and_default" strategy', () => {
94
- expect(isPrefixAndDefaultStrategy('prefix_and_default')).toBe(true)
95
- })
96
-
97
- test('should return false for other strategies', () => {
98
- expect(isPrefixAndDefaultStrategy('no_prefix')).toBe(false)
99
- expect(isPrefixAndDefaultStrategy('prefix')).toBe(false)
100
- expect(isPrefixAndDefaultStrategy('prefix_except_default')).toBe(false)
101
- })
102
- })
103
- })
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2018",
4
- "module": "esnext",
5
- "moduleResolution": "node",
6
-
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "outDir": "./dist",
12
- "declaration": true,
13
- "declarationDir": "./dist",
14
- "sourceMap": true,
15
- "rootDir": "./src",
16
- "baseUrl": "./",
17
- "paths": {
18
- "*": ["node_modules/*", "src/types/*"]
19
- },
20
- "types": ["jest", "node"]
21
- },
22
- "include": ["src/**/*"],
23
- "exclude": ["node_modules", "dist", "tests"]
24
- }
package/vite.config.mts DELETED
@@ -1,22 +0,0 @@
1
- // @ts-nocheck
2
- import { resolve } from 'node:path'
3
- import { defineConfig } from 'vite'
4
- import dts from 'vite-plugin-dts'
5
-
6
- export default defineConfig({
7
- build: {
8
- lib: {
9
- entry: resolve(__dirname, 'src/index.ts'),
10
- name: '@i18n-micro/core',
11
- formats: ['cjs', 'es'],
12
- fileName: (format) => `index.${format === 'cjs' ? 'cjs' : 'mjs'}`,
13
- },
14
- rollupOptions: {
15
- external: [],
16
- output: {
17
- exports: 'named',
18
- },
19
- },
20
- },
21
- plugins: [dts()],
22
- })