ansuko 1.3.15 → 2.0.0
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.
- package/README.ja.md +48 -32
- package/README.md +44 -28
- package/README.zh.md +44 -28
- package/dist/index.d.ts +17 -312
- package/dist/index.js +1 -15
- package/dist/plugins/geo.d.ts +14 -4
- package/dist/plugins/geo.js +6 -6
- package/dist/plugins/ja.d.ts +13 -5
- package/dist/plugins/ja.js +10 -10
- package/dist/plugins/prototype.d.ts +1 -2
- package/dist/plugins/prototype.js +7 -5
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -92,14 +92,14 @@ ansukoは最小限のコア + プラグインアーキテクチャを採用し
|
|
|
92
92
|
import _ from 'ansuko' // ~20KB
|
|
93
93
|
|
|
94
94
|
// 必要に応じて日本語サポートを追加
|
|
95
|
-
import
|
|
96
|
-
const extended = _.extend(jaPlugin) // +5KB
|
|
95
|
+
import 'ansuko/plugins/ja' // +5KB(side-effect import)
|
|
97
96
|
|
|
98
97
|
// マッピングアプリ用にGIS機能を追加
|
|
99
|
-
import
|
|
100
|
-
const full = extended.extend(geoPlugin) // +100KB
|
|
98
|
+
import 'ansuko/plugins/geo' // +100KB
|
|
101
99
|
```
|
|
102
100
|
|
|
101
|
+
> **v2 ノート**: プラグインは side-effect import で読み込む形式に変わりました。`import 'ansuko/plugins/<name>'` するだけで、`_` の実体と TypeScript の型 (declare module merging 経由) が同時に拡張されます。v1 で使われていた `_.extend(plugin)` API は v2 で削除されました — 後述の [v1 からの移行](#v1-からの移行) を参照。
|
|
102
|
+
|
|
103
103
|
## クイックスタート
|
|
104
104
|
|
|
105
105
|
### 基本的な使い方
|
|
@@ -140,39 +140,35 @@ const items = _.swallowMap([1, 2, 3], item => processItem(item), true) // エ
|
|
|
140
140
|
|
|
141
141
|
```typescript
|
|
142
142
|
import _ from 'ansuko'
|
|
143
|
-
import
|
|
143
|
+
import 'ansuko/plugins/ja'
|
|
144
144
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
extended.toHalfWidth('ABCー123', '-') // 'ABC-123'
|
|
150
|
-
extended.haifun('test‐data', '-') // 'test-data'
|
|
145
|
+
_.kanaToFull('ガギ') // 'ガギ'
|
|
146
|
+
_.kanaToHira('アイウ') // 'あいう'
|
|
147
|
+
_.toHalfWidth('ABCー123', '-') // 'ABC-123'
|
|
148
|
+
_.haifun('test‐data', '-') // 'test-data'
|
|
151
149
|
```
|
|
152
150
|
|
|
153
151
|
#### Geoプラグイン
|
|
154
152
|
|
|
155
153
|
```typescript
|
|
156
154
|
import _ from 'ansuko'
|
|
157
|
-
import
|
|
158
|
-
|
|
159
|
-
const extended = _.extend(geoPlugin)
|
|
155
|
+
import 'ansuko/plugins/geo'
|
|
160
156
|
|
|
161
157
|
// 様々な形式をGeoJSONに変換
|
|
162
|
-
|
|
158
|
+
_.toPointGeoJson([139.7671, 35.6812])
|
|
163
159
|
// => { type: 'Point', coordinates: [139.7671, 35.6812] }
|
|
164
160
|
|
|
165
|
-
|
|
161
|
+
_.toPointGeoJson({ lat: 35.6895, lng: 139.6917 })
|
|
166
162
|
// => { type: 'Point', coordinates: [139.6917, 35.6895] }
|
|
167
163
|
|
|
168
164
|
// 複数のポリゴンを結合
|
|
169
|
-
const unified =
|
|
165
|
+
const unified = _.unionPolygon([polygon1, polygon2])
|
|
170
166
|
|
|
171
167
|
// MapBoxユーティリティ
|
|
172
|
-
|
|
168
|
+
_.mZoomInterpolate({ 10: 1, 15: 5, 20: 10 })
|
|
173
169
|
// => ["interpolate", ["linear"], ["zoom"], 10, 1, 15, 5, 20, 10]
|
|
174
170
|
|
|
175
|
-
|
|
171
|
+
_.mProps({
|
|
176
172
|
fillColor: "#ff0000",
|
|
177
173
|
sourceLayer: "buildings",
|
|
178
174
|
visibility: true
|
|
@@ -183,32 +179,52 @@ extended.mProps({
|
|
|
183
179
|
#### Prototypeプラグイン
|
|
184
180
|
|
|
185
181
|
```typescript
|
|
186
|
-
import
|
|
187
|
-
import prototypePlugin from 'ansuko/plugins/prototype'
|
|
188
|
-
|
|
189
|
-
_.extend(prototypePlugin)
|
|
182
|
+
import 'ansuko/plugins/prototype'
|
|
190
183
|
|
|
191
184
|
// Array.prototypeが拡張される
|
|
192
185
|
[1, 2, 3].notMap(n => n > 1) // [true, false, false]
|
|
193
186
|
[1, 2, 3].notFilter(n => n % 2) // [2](偶数)
|
|
194
187
|
```
|
|
195
188
|
|
|
196
|
-
###
|
|
189
|
+
### 複数プラグインの併用
|
|
197
190
|
|
|
198
191
|
```typescript
|
|
199
192
|
import _ from 'ansuko'
|
|
200
|
-
import
|
|
201
|
-
import
|
|
193
|
+
import 'ansuko/plugins/ja'
|
|
194
|
+
import 'ansuko/plugins/geo'
|
|
195
|
+
|
|
196
|
+
// 日本語とGeoユーティリティの両方が `_` で使える
|
|
197
|
+
_.kanaToHira('アイウ')
|
|
198
|
+
_.toPointGeoJson([139.7, 35.6])
|
|
199
|
+
```
|
|
202
200
|
|
|
203
|
-
|
|
204
|
-
.extend(jaPlugin)
|
|
205
|
-
.extend(geoPlugin)
|
|
201
|
+
各プラグインは複数ファイルから import されても登録は1回のみです(重複登録ガードを内蔵)。
|
|
206
202
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
203
|
+
## v1 からの移行
|
|
204
|
+
|
|
205
|
+
v2 では `_.extend(plugin)` を廃止し、side-effect import に統一しました。移行は機械的です:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
// v1
|
|
209
|
+
import _ from 'ansuko'
|
|
210
|
+
import jaPlugin from 'ansuko/plugins/ja'
|
|
211
|
+
const ansuko = _.extend(jaPlugin)
|
|
212
|
+
ansuko.kanaToFull('ガ')
|
|
213
|
+
|
|
214
|
+
// v2
|
|
215
|
+
import _ from 'ansuko'
|
|
216
|
+
import 'ansuko/plugins/ja'
|
|
217
|
+
_.kanaToFull('ガ')
|
|
210
218
|
```
|
|
211
219
|
|
|
220
|
+
変更の理由:
|
|
221
|
+
|
|
222
|
+
- **TypeScript のサジェストが本当に効くようになりました。** v1 の `_.extend()` は新しい型を返していましたが、元の `_` 自体の型は変わらないため IDE 上で `_.` を打ってもプラグインの関数が候補に出てきませんでした。v2 は `declare module` merging で `_` 自体を型レベルで拡張します。
|
|
223
|
+
- **Tree-shaking が正直になります。** プラグインを import しなければバンドルに含まれません。
|
|
224
|
+
- **lodash 型を330行手書きしていた問題を解消。** `AnsukoType` は `Omit<LoDashStatic, ...>` を継承するようになり、lodash 本来のジェネリクスもそのまま使えます。
|
|
225
|
+
|
|
226
|
+
v1 で `_.extend(a).extend(b)` のように chain していた場合は、2回の side-effect import に置き換えてください。
|
|
227
|
+
|
|
212
228
|
## 主な機能
|
|
213
229
|
|
|
214
230
|
### 拡張されたlodash関数
|
package/README.md
CHANGED
|
@@ -171,14 +171,14 @@ This means you only pay for what you use!
|
|
|
171
171
|
import _ from 'ansuko' // ~20KB
|
|
172
172
|
|
|
173
173
|
// Add Japanese support when needed
|
|
174
|
-
import
|
|
175
|
-
_.extend(jaPlugin) // +5KB
|
|
174
|
+
import 'ansuko/plugins/ja' // +5KB (side-effect import)
|
|
176
175
|
|
|
177
176
|
// Add GIS features for mapping apps
|
|
178
|
-
import
|
|
179
|
-
_.extend(geoPlugin) // +100KB
|
|
177
|
+
import 'ansuko/plugins/geo' // +100KB
|
|
180
178
|
```
|
|
181
179
|
|
|
180
|
+
> **v2 Note**: Plugins are now loaded as side-effect imports. Just `import 'ansuko/plugins/<name>'` once and `_` is automatically augmented in both runtime and type system (via TypeScript's `declare module` merging). The legacy `_.extend(plugin)` API has been removed in v2 — see [Migration from v1](#migration-from-v1) below.
|
|
181
|
+
|
|
182
182
|
## Quick Start
|
|
183
183
|
|
|
184
184
|
### Basic Usage
|
|
@@ -219,9 +219,7 @@ const items = _.swallowMap([1, 2, 3], item => processItem(item), true) // filte
|
|
|
219
219
|
|
|
220
220
|
```typescript
|
|
221
221
|
import _ from 'ansuko'
|
|
222
|
-
import
|
|
223
|
-
|
|
224
|
-
_.extend(jaPlugin)
|
|
222
|
+
import 'ansuko/plugins/ja'
|
|
225
223
|
|
|
226
224
|
_.kanaToFull('ガギ') // 'ガギ'
|
|
227
225
|
_.kanaToHira('アイウ') // 'あいう'
|
|
@@ -233,25 +231,23 @@ _.haifun('test‐data', '-') // 'test-data'
|
|
|
233
231
|
|
|
234
232
|
```typescript
|
|
235
233
|
import _ from 'ansuko'
|
|
236
|
-
import
|
|
237
|
-
|
|
238
|
-
const extended = _.extend(geoPlugin)
|
|
234
|
+
import 'ansuko/plugins/geo'
|
|
239
235
|
|
|
240
236
|
// Convert various formats to GeoJSON
|
|
241
|
-
|
|
237
|
+
_.toPointGeoJson([139.7671, 35.6812])
|
|
242
238
|
// => { type: 'Point', coordinates: [139.7671, 35.6812] }
|
|
243
239
|
|
|
244
|
-
|
|
240
|
+
_.toPointGeoJson({ lat: 35.6895, lng: 139.6917 })
|
|
245
241
|
// => { type: 'Point', coordinates: [139.6917, 35.6895] }
|
|
246
242
|
|
|
247
243
|
// Union multiple polygons
|
|
248
|
-
const unified =
|
|
244
|
+
const unified = _.unionPolygon([polygon1, polygon2])
|
|
249
245
|
|
|
250
246
|
// MapBox utilities
|
|
251
|
-
|
|
247
|
+
_.mZoomInterpolate({ 10: 1, 15: 5, 20: 10 })
|
|
252
248
|
// => ["interpolate", ["linear"], ["zoom"], 10, 1, 15, 5, 20, 10]
|
|
253
249
|
|
|
254
|
-
|
|
250
|
+
_.mProps({
|
|
255
251
|
fillColor: "#ff0000",
|
|
256
252
|
sourceLayer: "buildings",
|
|
257
253
|
visibility: true
|
|
@@ -262,32 +258,52 @@ extended.mProps({
|
|
|
262
258
|
#### Prototype Plugin
|
|
263
259
|
|
|
264
260
|
```typescript
|
|
265
|
-
import
|
|
266
|
-
import prototypePlugin from 'ansuko/plugins/prototype'
|
|
267
|
-
|
|
268
|
-
_.extend(prototypePlugin)
|
|
261
|
+
import 'ansuko/plugins/prototype'
|
|
269
262
|
|
|
270
263
|
// Now Array.prototype is extended
|
|
271
264
|
[1, 2, 3].notMap(n => n > 1) // [true, false, false]
|
|
272
265
|
[1, 2, 3].notFilter(n => n % 2) // [2] (even numbers)
|
|
273
266
|
```
|
|
274
267
|
|
|
275
|
-
###
|
|
268
|
+
### Combining Plugins
|
|
276
269
|
|
|
277
270
|
```typescript
|
|
278
271
|
import _ from 'ansuko'
|
|
279
|
-
import
|
|
280
|
-
import
|
|
272
|
+
import 'ansuko/plugins/ja'
|
|
273
|
+
import 'ansuko/plugins/geo'
|
|
274
|
+
|
|
275
|
+
// Now you have both Japanese and Geo utilities on `_`
|
|
276
|
+
_.kanaToHira('アイウ')
|
|
277
|
+
_.toPointGeoJson([139.7, 35.6])
|
|
278
|
+
```
|
|
281
279
|
|
|
282
|
-
|
|
283
|
-
.extend(jaPlugin)
|
|
284
|
-
.extend(geoPlugin)
|
|
280
|
+
Each plugin registers itself exactly once, even if imported from multiple files (a duplicate-registration guard is built in).
|
|
285
281
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
282
|
+
## Migration from v1
|
|
283
|
+
|
|
284
|
+
v2 removes `_.extend(plugin)` in favor of side-effect imports. The migration is mechanical:
|
|
285
|
+
|
|
286
|
+
```typescript
|
|
287
|
+
// v1
|
|
288
|
+
import _ from 'ansuko'
|
|
289
|
+
import jaPlugin from 'ansuko/plugins/ja'
|
|
290
|
+
const ansuko = _.extend(jaPlugin)
|
|
291
|
+
ansuko.kanaToFull('ガ')
|
|
292
|
+
|
|
293
|
+
// v2
|
|
294
|
+
import _ from 'ansuko'
|
|
295
|
+
import 'ansuko/plugins/ja'
|
|
296
|
+
_.kanaToFull('ガ')
|
|
289
297
|
```
|
|
290
298
|
|
|
299
|
+
Why this change:
|
|
300
|
+
|
|
301
|
+
- **TypeScript autocompletion now actually works.** v1's `_.extend()` returned a new type, but the original `_` reference's type stayed the same — so IDE suggestions never appeared on `_`. v2 uses TypeScript `declare module` merging so `_` itself is augmented at the type level.
|
|
302
|
+
- **Tree-shaking is honest.** Don't import a plugin = its code is not bundled.
|
|
303
|
+
- **No more 330-line manual lodash type list.** `AnsukoType` now extends `Omit<LoDashStatic, ...>`, so lodash's own types are reused (with proper generics).
|
|
304
|
+
|
|
305
|
+
If you previously did chained `_.extend(a).extend(b)`, replace it with two side-effect imports.
|
|
306
|
+
|
|
291
307
|
## Documentation
|
|
292
308
|
|
|
293
309
|
For detailed information, see:
|
package/README.zh.md
CHANGED
|
@@ -166,14 +166,14 @@ ansuko使用最小核心 + 插件架构来保持你的包大小小:
|
|
|
166
166
|
import _ from 'ansuko' // ~20KB
|
|
167
167
|
|
|
168
168
|
// 按需加入日文支持
|
|
169
|
-
import
|
|
170
|
-
const extended = _.extend(jaPlugin) // +5KB
|
|
169
|
+
import 'ansuko/plugins/ja' // +5KB(副作用引入)
|
|
171
170
|
|
|
172
171
|
// 地图类应用再挂载 GIS
|
|
173
|
-
import
|
|
174
|
-
const full = extended.extend(geoPlugin) // +100KB
|
|
172
|
+
import 'ansuko/plugins/geo' // +100KB
|
|
175
173
|
```
|
|
176
174
|
|
|
175
|
+
> **v2 提示**:插件改为副作用引入。只需 `import 'ansuko/plugins/<name>'` 一次,`_` 在运行时和 TypeScript 类型层面(通过 `declare module` 合并)都会被自动扩展。v1 的 `_.extend(plugin)` API 已在 v2 中移除 —— 详见下方的[从 v1 迁移](#从-v1-迁移)。
|
|
176
|
+
|
|
177
177
|
## 快速开始
|
|
178
178
|
|
|
179
179
|
### 基本用法
|
|
@@ -214,9 +214,7 @@ const items = _.swallowMap([1, 2, 3], item => processItem(item), true) // 过
|
|
|
214
214
|
|
|
215
215
|
```typescript
|
|
216
216
|
import _ from 'ansuko'
|
|
217
|
-
import
|
|
218
|
-
|
|
219
|
-
_.extend(jaPlugin)
|
|
217
|
+
import 'ansuko/plugins/ja'
|
|
220
218
|
|
|
221
219
|
_.kanaToFull('ガギ') // 'ガギ'
|
|
222
220
|
_.kanaToHira('アイウ') // 'あいう'
|
|
@@ -228,25 +226,23 @@ _.haifun('test‐data', '-') // 'test-data'
|
|
|
228
226
|
|
|
229
227
|
```typescript
|
|
230
228
|
import _ from 'ansuko'
|
|
231
|
-
import
|
|
232
|
-
|
|
233
|
-
const extended = _.extend(geoPlugin)
|
|
229
|
+
import 'ansuko/plugins/geo'
|
|
234
230
|
|
|
235
231
|
// 将各种格式转换为 GeoJSON
|
|
236
|
-
|
|
232
|
+
_.toPointGeoJson([139.7671, 35.6812])
|
|
237
233
|
// => { type: 'Point', coordinates: [139.7671, 35.6812] }
|
|
238
234
|
|
|
239
|
-
|
|
235
|
+
_.toPointGeoJson({ lat: 35.6895, lng: 139.6917 })
|
|
240
236
|
// => { type: 'Point', coordinates: [139.6917, 35.6895] }
|
|
241
237
|
|
|
242
238
|
// 合并多个多边形
|
|
243
|
-
const unified =
|
|
239
|
+
const unified = _.unionPolygon([polygon1, polygon2])
|
|
244
240
|
|
|
245
241
|
// MapBox 工具
|
|
246
|
-
|
|
242
|
+
_.mZoomInterpolate({ 10: 1, 15: 5, 20: 10 })
|
|
247
243
|
// => ["interpolate", ["linear"], ["zoom"], 10, 1, 15, 5, 20, 10]
|
|
248
244
|
|
|
249
|
-
|
|
245
|
+
_.mProps({
|
|
250
246
|
fillColor: "#ff0000",
|
|
251
247
|
sourceLayer: "buildings",
|
|
252
248
|
visibility: true
|
|
@@ -257,32 +253,52 @@ extended.mProps({
|
|
|
257
253
|
#### 原型插件
|
|
258
254
|
|
|
259
255
|
```typescript
|
|
260
|
-
import
|
|
261
|
-
import prototypePlugin from 'ansuko/plugins/prototype'
|
|
262
|
-
|
|
263
|
-
_.extend(prototypePlugin)
|
|
256
|
+
import 'ansuko/plugins/prototype'
|
|
264
257
|
|
|
265
258
|
// 现在 Array.prototype 已扩展
|
|
266
259
|
[1, 2, 3].notMap(n => n > 1) // [true, false, false]
|
|
267
260
|
[1, 2, 3].notFilter(n => n % 2) // [2](偶数)
|
|
268
261
|
```
|
|
269
262
|
|
|
270
|
-
###
|
|
263
|
+
### 同时使用多个插件
|
|
271
264
|
|
|
272
265
|
```typescript
|
|
273
266
|
import _ from 'ansuko'
|
|
274
|
-
import
|
|
275
|
-
import
|
|
267
|
+
import 'ansuko/plugins/ja'
|
|
268
|
+
import 'ansuko/plugins/geo'
|
|
269
|
+
|
|
270
|
+
// 现在 `_` 上同时拥有日文和地理工具
|
|
271
|
+
_.kanaToHira('アイウ')
|
|
272
|
+
_.toPointGeoJson([139.7, 35.6])
|
|
273
|
+
```
|
|
276
274
|
|
|
277
|
-
|
|
278
|
-
.extend(jaPlugin)
|
|
279
|
-
.extend(geoPlugin)
|
|
275
|
+
每个插件即使被多个文件 import,也只会注册一次(内置了重复注册防护)。
|
|
280
276
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
277
|
+
## 从 v1 迁移
|
|
278
|
+
|
|
279
|
+
v2 移除了 `_.extend(plugin)`,改为副作用引入。迁移非常机械:
|
|
280
|
+
|
|
281
|
+
```typescript
|
|
282
|
+
// v1
|
|
283
|
+
import _ from 'ansuko'
|
|
284
|
+
import jaPlugin from 'ansuko/plugins/ja'
|
|
285
|
+
const ansuko = _.extend(jaPlugin)
|
|
286
|
+
ansuko.kanaToFull('ガ')
|
|
287
|
+
|
|
288
|
+
// v2
|
|
289
|
+
import _ from 'ansuko'
|
|
290
|
+
import 'ansuko/plugins/ja'
|
|
291
|
+
_.kanaToFull('ガ')
|
|
284
292
|
```
|
|
285
293
|
|
|
294
|
+
变更原因:
|
|
295
|
+
|
|
296
|
+
- **TypeScript 自动补全终于真正起作用了。** v1 的 `_.extend()` 会返回新类型,但原 `_` 引用的类型不变 —— 因此在 IDE 里 `_.` 永远不会出现插件的方法提示。v2 通过 TypeScript `declare module` 合并直接扩展 `_` 自身的类型。
|
|
297
|
+
- **Tree-shaking 真实可靠。** 不 import 的插件不会被打包。
|
|
298
|
+
- **告别 330 行手写 lodash 类型列表。** `AnsukoType` 现在继承 `Omit<LoDashStatic, ...>`,lodash 自身的泛型类型也得以保留。
|
|
299
|
+
|
|
300
|
+
如果你之前使用 `_.extend(a).extend(b)` 的链式写法,请改为两次副作用引入。
|
|
301
|
+
|
|
286
302
|
## 文档
|
|
287
303
|
|
|
288
304
|
更多详细信息,请参阅:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import lodash from "lodash";
|
|
1
|
+
import lodash, { type LoDashStatic } from "lodash";
|
|
2
2
|
/**
|
|
3
3
|
* Checks if the value is a non-empty string. null/undefined/empty string -> false.
|
|
4
4
|
* @param str - Value to check
|
|
@@ -209,21 +209,20 @@ declare const swallowMap: <T, U>(array: T[] | undefined | null, fn: (item: T, in
|
|
|
209
209
|
* @category Array Utilities
|
|
210
210
|
*/
|
|
211
211
|
declare const arrayDepth: (ary: unknown) => number;
|
|
212
|
-
/**
|
|
213
|
-
* Extends ansuko with a plugin and returns the augmented instance.
|
|
214
|
-
* @param plugin - Plugin function
|
|
215
|
-
* @returns Extended instance
|
|
216
|
-
* @example const extended = lodash.extend(jaPlugin)
|
|
217
|
-
* @category Core Functions
|
|
218
|
-
*/
|
|
219
|
-
declare const extend: <T extends AnsukoType, E>(this: T, plugin: (a: T) => T & E) => T & E;
|
|
220
212
|
export type ChangesOptions = {
|
|
221
213
|
keyExcludes?: boolean;
|
|
222
214
|
};
|
|
223
215
|
type ChangesAfterCallback<T> = (value: T) => any | Promise<any>;
|
|
224
216
|
type ChangesAfterFinallyCallback<T> = (value: T, res: any) => any | Promise<any>;
|
|
225
|
-
|
|
226
|
-
|
|
217
|
+
type AnsukoOverriddenKeys = 'isEmpty' | 'toNumber' | 'castArray' | 'extend';
|
|
218
|
+
/**
|
|
219
|
+
* ansuko 本体の型。lodash の全関数 (上書き対象を除く) をそのまま継承し、
|
|
220
|
+
* ansuko 独自関数を追加した形になる。
|
|
221
|
+
*
|
|
222
|
+
* プラグインを読み込むと、各プラグインの d.ts に書かれた declaration merging により
|
|
223
|
+
* このインターフェースが自動的に拡張される。
|
|
224
|
+
*/
|
|
225
|
+
export interface AnsukoType extends Omit<LoDashStatic, AnsukoOverriddenKeys> {
|
|
227
226
|
isValidStr: typeof isValidStr;
|
|
228
227
|
valueOr: typeof valueOr;
|
|
229
228
|
emptyOr: typeof emptyOr;
|
|
@@ -245,307 +244,13 @@ export interface AnsukoType {
|
|
|
245
244
|
isEmptyOrg: typeof lodash.isEmpty;
|
|
246
245
|
toNumberOrg: typeof lodash.toNumber;
|
|
247
246
|
castArrayOrg: typeof lodash.castArray;
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
at: typeof lodash.at;
|
|
256
|
-
attempt: typeof lodash.attempt;
|
|
257
|
-
before: typeof lodash.before;
|
|
258
|
-
bind: typeof lodash.bind;
|
|
259
|
-
bindAll: typeof lodash.bindAll;
|
|
260
|
-
bindKey: typeof lodash.bindKey;
|
|
261
|
-
camelCase: typeof lodash.camelCase;
|
|
262
|
-
capitalize: typeof lodash.capitalize;
|
|
263
|
-
ceil: typeof lodash.ceil;
|
|
264
|
-
chain: typeof lodash.chain;
|
|
265
|
-
chunk: typeof lodash.chunk;
|
|
266
|
-
clamp: typeof lodash.clamp;
|
|
267
|
-
clone: typeof lodash.clone;
|
|
268
|
-
cloneDeep: typeof lodash.cloneDeep;
|
|
269
|
-
cloneDeepWith: typeof lodash.cloneDeepWith;
|
|
270
|
-
cloneWith: typeof lodash.cloneWith;
|
|
271
|
-
compact: typeof lodash.compact;
|
|
272
|
-
concat: typeof lodash.concat;
|
|
273
|
-
cond: typeof lodash.cond;
|
|
274
|
-
conforms: typeof lodash.conforms;
|
|
275
|
-
conformsTo: typeof lodash.conformsTo;
|
|
276
|
-
constant: typeof lodash.constant;
|
|
277
|
-
countBy: typeof lodash.countBy;
|
|
278
|
-
create: typeof lodash.create;
|
|
279
|
-
curry: typeof lodash.curry;
|
|
280
|
-
curryRight: typeof lodash.curryRight;
|
|
281
|
-
debounce: typeof lodash.debounce;
|
|
282
|
-
deburr: typeof lodash.deburr;
|
|
283
|
-
defaultTo: typeof lodash.defaultTo;
|
|
284
|
-
defaults: typeof lodash.defaults;
|
|
285
|
-
defaultsDeep: typeof lodash.defaultsDeep;
|
|
286
|
-
defer: typeof lodash.defer;
|
|
287
|
-
delay: typeof lodash.delay;
|
|
288
|
-
difference: typeof lodash.difference;
|
|
289
|
-
differenceBy: typeof lodash.differenceBy;
|
|
290
|
-
differenceWith: typeof lodash.differenceWith;
|
|
291
|
-
divide: typeof lodash.divide;
|
|
292
|
-
drop: typeof lodash.drop;
|
|
293
|
-
dropRight: typeof lodash.dropRight;
|
|
294
|
-
dropRightWhile: typeof lodash.dropRightWhile;
|
|
295
|
-
dropWhile: typeof lodash.dropWhile;
|
|
296
|
-
each: typeof lodash.each;
|
|
297
|
-
eachRight: typeof lodash.eachRight;
|
|
298
|
-
endsWith: typeof lodash.endsWith;
|
|
299
|
-
entries: typeof lodash.entries;
|
|
300
|
-
entriesIn: typeof lodash.entriesIn;
|
|
301
|
-
eq: typeof lodash.eq;
|
|
302
|
-
escape: typeof lodash.escape;
|
|
303
|
-
escapeRegExp: typeof lodash.escapeRegExp;
|
|
304
|
-
every: typeof lodash.every;
|
|
305
|
-
extendWith: typeof lodash.extendWith;
|
|
306
|
-
fill: typeof lodash.fill;
|
|
307
|
-
filter: typeof lodash.filter;
|
|
308
|
-
find: typeof lodash.find;
|
|
309
|
-
findIndex: typeof lodash.findIndex;
|
|
310
|
-
findKey: typeof lodash.findKey;
|
|
311
|
-
findLast: typeof lodash.findLast;
|
|
312
|
-
findLastIndex: typeof lodash.findLastIndex;
|
|
313
|
-
findLastKey: typeof lodash.findLastKey;
|
|
314
|
-
first: typeof lodash.first;
|
|
315
|
-
flatMap: typeof lodash.flatMap;
|
|
316
|
-
flatMapDeep: typeof lodash.flatMapDeep;
|
|
317
|
-
flatMapDepth: typeof lodash.flatMapDepth;
|
|
318
|
-
flatten: typeof lodash.flatten;
|
|
319
|
-
flattenDeep: typeof lodash.flattenDeep;
|
|
320
|
-
flattenDepth: typeof lodash.flattenDepth;
|
|
321
|
-
flip: typeof lodash.flip;
|
|
322
|
-
floor: typeof lodash.floor;
|
|
323
|
-
flow: typeof lodash.flow;
|
|
324
|
-
flowRight: typeof lodash.flowRight;
|
|
325
|
-
forEach: typeof lodash.forEach;
|
|
326
|
-
forEachRight: typeof lodash.forEachRight;
|
|
327
|
-
forIn: typeof lodash.forIn;
|
|
328
|
-
forInRight: typeof lodash.forInRight;
|
|
329
|
-
forOwn: typeof lodash.forOwn;
|
|
330
|
-
forOwnRight: typeof lodash.forOwnRight;
|
|
331
|
-
fromPairs: typeof lodash.fromPairs;
|
|
332
|
-
functions: typeof lodash.functions;
|
|
333
|
-
functionsIn: typeof lodash.functionsIn;
|
|
334
|
-
get: typeof lodash.get;
|
|
335
|
-
groupBy: typeof lodash.groupBy;
|
|
336
|
-
gt: typeof lodash.gt;
|
|
337
|
-
gte: typeof lodash.gte;
|
|
338
|
-
has: typeof lodash.has;
|
|
339
|
-
hasIn: typeof lodash.hasIn;
|
|
340
|
-
head: typeof lodash.head;
|
|
341
|
-
identity: typeof lodash.identity;
|
|
342
|
-
inRange: typeof lodash.inRange;
|
|
343
|
-
includes: typeof lodash.includes;
|
|
344
|
-
indexOf: typeof lodash.indexOf;
|
|
345
|
-
initial: typeof lodash.initial;
|
|
346
|
-
intersection: typeof lodash.intersection;
|
|
347
|
-
intersectionBy: typeof lodash.intersectionBy;
|
|
348
|
-
intersectionWith: typeof lodash.intersectionWith;
|
|
349
|
-
invert: typeof lodash.invert;
|
|
350
|
-
invertBy: typeof lodash.invertBy;
|
|
351
|
-
invoke: typeof lodash.invoke;
|
|
352
|
-
invokeMap: typeof lodash.invokeMap;
|
|
353
|
-
isArguments: typeof lodash.isArguments;
|
|
354
|
-
isArray: typeof lodash.isArray;
|
|
355
|
-
isArrayBuffer: typeof lodash.isArrayBuffer;
|
|
356
|
-
isArrayLike: typeof lodash.isArrayLike;
|
|
357
|
-
isArrayLikeObject: typeof lodash.isArrayLikeObject;
|
|
358
|
-
isBoolean: typeof lodash.isBoolean;
|
|
359
|
-
isBuffer: typeof lodash.isBuffer;
|
|
360
|
-
isDate: typeof lodash.isDate;
|
|
361
|
-
isElement: typeof lodash.isElement;
|
|
362
|
-
isEqual: typeof lodash.isEqual;
|
|
363
|
-
isEqualWith: typeof lodash.isEqualWith;
|
|
364
|
-
isError: typeof lodash.isError;
|
|
365
|
-
isFinite: typeof lodash.isFinite;
|
|
366
|
-
isFunction: typeof lodash.isFunction;
|
|
367
|
-
isInteger: typeof lodash.isInteger;
|
|
368
|
-
isLength: typeof lodash.isLength;
|
|
369
|
-
isMap: typeof lodash.isMap;
|
|
370
|
-
isMatch: typeof lodash.isMatch;
|
|
371
|
-
isMatchWith: typeof lodash.isMatchWith;
|
|
372
|
-
isNaN: typeof lodash.isNaN;
|
|
373
|
-
isNative: typeof lodash.isNative;
|
|
374
|
-
isNil: typeof lodash.isNil;
|
|
375
|
-
isNull: typeof lodash.isNull;
|
|
376
|
-
isNumber: typeof lodash.isNumber;
|
|
377
|
-
isObject: typeof lodash.isObject;
|
|
378
|
-
isObjectLike: typeof lodash.isObjectLike;
|
|
379
|
-
isPlainObject: typeof lodash.isPlainObject;
|
|
380
|
-
isRegExp: typeof lodash.isRegExp;
|
|
381
|
-
isSafeInteger: typeof lodash.isSafeInteger;
|
|
382
|
-
isSet: typeof lodash.isSet;
|
|
383
|
-
isString: typeof lodash.isString;
|
|
384
|
-
isSymbol: typeof lodash.isSymbol;
|
|
385
|
-
isTypedArray: typeof lodash.isTypedArray;
|
|
386
|
-
isUndefined: typeof lodash.isUndefined;
|
|
387
|
-
isWeakMap: typeof lodash.isWeakMap;
|
|
388
|
-
isWeakSet: typeof lodash.isWeakSet;
|
|
389
|
-
iteratee: typeof lodash.iteratee;
|
|
390
|
-
join: typeof lodash.join;
|
|
391
|
-
kebabCase: typeof lodash.kebabCase;
|
|
392
|
-
keyBy: typeof lodash.keyBy;
|
|
393
|
-
keys: typeof lodash.keys;
|
|
394
|
-
keysIn: typeof lodash.keysIn;
|
|
395
|
-
last: typeof lodash.last;
|
|
396
|
-
lastIndexOf: typeof lodash.lastIndexOf;
|
|
397
|
-
lowerCase: typeof lodash.lowerCase;
|
|
398
|
-
lowerFirst: typeof lodash.lowerFirst;
|
|
399
|
-
lt: typeof lodash.lt;
|
|
400
|
-
lte: typeof lodash.lte;
|
|
401
|
-
map: typeof lodash.map;
|
|
402
|
-
mapKeys: typeof lodash.mapKeys;
|
|
403
|
-
mapValues: typeof lodash.mapValues;
|
|
404
|
-
matches: typeof lodash.matches;
|
|
405
|
-
matchesProperty: typeof lodash.matchesProperty;
|
|
406
|
-
max: typeof lodash.max;
|
|
407
|
-
maxBy: typeof lodash.maxBy;
|
|
408
|
-
mean: typeof lodash.mean;
|
|
409
|
-
meanBy: typeof lodash.meanBy;
|
|
410
|
-
memoize: typeof lodash.memoize;
|
|
411
|
-
merge: typeof lodash.merge;
|
|
412
|
-
mergeWith: typeof lodash.mergeWith;
|
|
413
|
-
method: typeof lodash.method;
|
|
414
|
-
methodOf: typeof lodash.methodOf;
|
|
415
|
-
min: typeof lodash.min;
|
|
416
|
-
minBy: typeof lodash.minBy;
|
|
417
|
-
mixin: typeof lodash.mixin;
|
|
418
|
-
multiply: typeof lodash.multiply;
|
|
419
|
-
negate: typeof lodash.negate;
|
|
420
|
-
noConflict: typeof lodash.noConflict;
|
|
421
|
-
noop: typeof lodash.noop;
|
|
422
|
-
now: typeof lodash.now;
|
|
423
|
-
nth: typeof lodash.nth;
|
|
424
|
-
nthArg: typeof lodash.nthArg;
|
|
425
|
-
omit: typeof lodash.omit;
|
|
426
|
-
omitBy: typeof lodash.omitBy;
|
|
427
|
-
once: typeof lodash.once;
|
|
428
|
-
orderBy: typeof lodash.orderBy;
|
|
429
|
-
over: typeof lodash.over;
|
|
430
|
-
overArgs: typeof lodash.overArgs;
|
|
431
|
-
overEvery: typeof lodash.overEvery;
|
|
432
|
-
overSome: typeof lodash.overSome;
|
|
433
|
-
pad: typeof lodash.pad;
|
|
434
|
-
padEnd: typeof lodash.padEnd;
|
|
435
|
-
padStart: typeof lodash.padStart;
|
|
436
|
-
parseInt: typeof lodash.parseInt;
|
|
437
|
-
partial: typeof lodash.partial;
|
|
438
|
-
partialRight: typeof lodash.partialRight;
|
|
439
|
-
partition: typeof lodash.partition;
|
|
440
|
-
pick: typeof lodash.pick;
|
|
441
|
-
pickBy: typeof lodash.pickBy;
|
|
442
|
-
property: typeof lodash.property;
|
|
443
|
-
propertyOf: typeof lodash.propertyOf;
|
|
444
|
-
pull: typeof lodash.pull;
|
|
445
|
-
pullAll: typeof lodash.pullAll;
|
|
446
|
-
pullAllBy: typeof lodash.pullAllBy;
|
|
447
|
-
pullAllWith: typeof lodash.pullAllWith;
|
|
448
|
-
pullAt: typeof lodash.pullAt;
|
|
449
|
-
random: typeof lodash.random;
|
|
450
|
-
range: typeof lodash.range;
|
|
451
|
-
rangeRight: typeof lodash.rangeRight;
|
|
452
|
-
rearg: typeof lodash.rearg;
|
|
453
|
-
reduce: typeof lodash.reduce;
|
|
454
|
-
reduceRight: typeof lodash.reduceRight;
|
|
455
|
-
reject: typeof lodash.reject;
|
|
456
|
-
remove: typeof lodash.remove;
|
|
457
|
-
repeat: typeof lodash.repeat;
|
|
458
|
-
replace: typeof lodash.replace;
|
|
459
|
-
rest: typeof lodash.rest;
|
|
460
|
-
result: typeof lodash.result;
|
|
461
|
-
reverse: typeof lodash.reverse;
|
|
462
|
-
round: typeof lodash.round;
|
|
463
|
-
runInContext: typeof lodash.runInContext;
|
|
464
|
-
sample: typeof lodash.sample;
|
|
465
|
-
sampleSize: typeof lodash.sampleSize;
|
|
466
|
-
set: typeof lodash.set;
|
|
467
|
-
setWith: typeof lodash.setWith;
|
|
468
|
-
shuffle: typeof lodash.shuffle;
|
|
469
|
-
size: typeof lodash.size;
|
|
470
|
-
slice: typeof lodash.slice;
|
|
471
|
-
snakeCase: typeof lodash.snakeCase;
|
|
472
|
-
some: typeof lodash.some;
|
|
473
|
-
sortBy: typeof lodash.sortBy;
|
|
474
|
-
sortedIndex: typeof lodash.sortedIndex;
|
|
475
|
-
sortedIndexBy: typeof lodash.sortedIndexBy;
|
|
476
|
-
sortedIndexOf: typeof lodash.sortedIndexOf;
|
|
477
|
-
sortedLastIndex: typeof lodash.sortedLastIndex;
|
|
478
|
-
sortedLastIndexBy: typeof lodash.sortedLastIndexBy;
|
|
479
|
-
sortedLastIndexOf: typeof lodash.sortedLastIndexOf;
|
|
480
|
-
sortedUniq: typeof lodash.sortedUniq;
|
|
481
|
-
sortedUniqBy: typeof lodash.sortedUniqBy;
|
|
482
|
-
split: typeof lodash.split;
|
|
483
|
-
spread: typeof lodash.spread;
|
|
484
|
-
startCase: typeof lodash.startCase;
|
|
485
|
-
startsWith: typeof lodash.startsWith;
|
|
486
|
-
stubArray: typeof lodash.stubArray;
|
|
487
|
-
stubFalse: typeof lodash.stubFalse;
|
|
488
|
-
stubObject: typeof lodash.stubObject;
|
|
489
|
-
stubString: typeof lodash.stubString;
|
|
490
|
-
stubTrue: typeof lodash.stubTrue;
|
|
491
|
-
subtract: typeof lodash.subtract;
|
|
492
|
-
sum: typeof lodash.sum;
|
|
493
|
-
sumBy: typeof lodash.sumBy;
|
|
494
|
-
tail: typeof lodash.tail;
|
|
495
|
-
take: typeof lodash.take;
|
|
496
|
-
takeRight: typeof lodash.takeRight;
|
|
497
|
-
takeRightWhile: typeof lodash.takeRightWhile;
|
|
498
|
-
takeWhile: typeof lodash.takeWhile;
|
|
499
|
-
tap: typeof lodash.tap;
|
|
500
|
-
template: typeof lodash.template;
|
|
501
|
-
throttle: typeof lodash.throttle;
|
|
502
|
-
thru: typeof lodash.thru;
|
|
503
|
-
times: typeof lodash.times;
|
|
504
|
-
toArray: typeof lodash.toArray;
|
|
505
|
-
toFinite: typeof lodash.toFinite;
|
|
506
|
-
toInteger: typeof lodash.toInteger;
|
|
507
|
-
toLength: typeof lodash.toLength;
|
|
508
|
-
toLower: typeof lodash.toLower;
|
|
509
|
-
toPairs: typeof lodash.toPairs;
|
|
510
|
-
toPairsIn: typeof lodash.toPairsIn;
|
|
511
|
-
toPath: typeof lodash.toPath;
|
|
512
|
-
toPlainObject: typeof lodash.toPlainObject;
|
|
513
|
-
toSafeInteger: typeof lodash.toSafeInteger;
|
|
514
|
-
toString: typeof lodash.toString;
|
|
515
|
-
toUpper: typeof lodash.toUpper;
|
|
516
|
-
transform: typeof lodash.transform;
|
|
517
|
-
trim: typeof lodash.trim;
|
|
518
|
-
trimEnd: typeof lodash.trimEnd;
|
|
519
|
-
trimStart: typeof lodash.trimStart;
|
|
520
|
-
truncate: typeof lodash.truncate;
|
|
521
|
-
unary: typeof lodash.unary;
|
|
522
|
-
unescape: typeof lodash.unescape;
|
|
523
|
-
union: typeof lodash.union;
|
|
524
|
-
unionBy: typeof lodash.unionBy;
|
|
525
|
-
unionWith: typeof lodash.unionWith;
|
|
526
|
-
uniq: typeof lodash.uniq;
|
|
527
|
-
uniqBy: typeof lodash.uniqBy;
|
|
528
|
-
uniqWith: typeof lodash.uniqWith;
|
|
529
|
-
uniqueId: typeof lodash.uniqueId;
|
|
530
|
-
unset: typeof lodash.unset;
|
|
531
|
-
unzip: typeof lodash.unzip;
|
|
532
|
-
unzipWith: typeof lodash.unzipWith;
|
|
533
|
-
update: typeof lodash.update;
|
|
534
|
-
updateWith: typeof lodash.updateWith;
|
|
535
|
-
upperCase: typeof lodash.upperCase;
|
|
536
|
-
upperFirst: typeof lodash.upperFirst;
|
|
537
|
-
values: typeof lodash.values;
|
|
538
|
-
valuesIn: typeof lodash.valuesIn;
|
|
539
|
-
without: typeof lodash.without;
|
|
540
|
-
words: typeof lodash.words;
|
|
541
|
-
wrap: typeof lodash.wrap;
|
|
542
|
-
xor: typeof lodash.xor;
|
|
543
|
-
xorBy: typeof lodash.xorBy;
|
|
544
|
-
xorWith: typeof lodash.xorWith;
|
|
545
|
-
zip: typeof lodash.zip;
|
|
546
|
-
zipObject: typeof lodash.zipObject;
|
|
547
|
-
zipObjectDeep: typeof lodash.zipObjectDeep;
|
|
548
|
-
zipWith: typeof lodash.zipWith;
|
|
247
|
+
/**
|
|
248
|
+
* 登録済みプラグイン名のレジストリ。
|
|
249
|
+
* プラグインの side-effect import 時に重複登録を防ぐために使用される。
|
|
250
|
+
* 通常コードから直接触らないこと。
|
|
251
|
+
* @internal
|
|
252
|
+
*/
|
|
253
|
+
__plugins: Set<string>;
|
|
549
254
|
}
|
|
550
255
|
declare const _: AnsukoType;
|
|
551
256
|
export default _;
|
package/dist/index.js
CHANGED
|
@@ -564,24 +564,9 @@ const arrayDepth = (ary) => {
|
|
|
564
564
|
}
|
|
565
565
|
return 1 + Math.min(...ary.map(arrayDepth));
|
|
566
566
|
};
|
|
567
|
-
/**
|
|
568
|
-
* Extends ansuko with a plugin and returns the augmented instance.
|
|
569
|
-
* @param plugin - Plugin function
|
|
570
|
-
* @returns Extended instance
|
|
571
|
-
* @example const extended = lodash.extend(jaPlugin)
|
|
572
|
-
* @category Core Functions
|
|
573
|
-
*/
|
|
574
|
-
const extend = function (plugin) {
|
|
575
|
-
if (typeof plugin === 'function') {
|
|
576
|
-
return plugin(this); // プラグインの戻り値をそのまま返す
|
|
577
|
-
}
|
|
578
|
-
return this;
|
|
579
|
-
};
|
|
580
|
-
// Ansuko型へのキャストを外し、より安全な unknown as LoDashStatic に変更
|
|
581
567
|
// 変数名を _ にすることで、VS Code の auto import 候補が `_` として表示される
|
|
582
568
|
const _ = {
|
|
583
569
|
...lodash,
|
|
584
|
-
extend,
|
|
585
570
|
isEmptyOrg: lodash.isEmpty,
|
|
586
571
|
toNumberOrg: lodash.toNumber,
|
|
587
572
|
castArrayOrg: lodash.castArray,
|
|
@@ -603,6 +588,7 @@ const _ = {
|
|
|
603
588
|
swallow,
|
|
604
589
|
swallowMap,
|
|
605
590
|
arrayDepth,
|
|
591
|
+
__plugins: new Set(),
|
|
606
592
|
};
|
|
607
593
|
export default _;
|
|
608
594
|
// 個別エクスポートはそのまま
|
package/dist/plugins/geo.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import GeoJSON from "geojson";
|
|
2
|
-
import { type AnsukoType } from "../index.js";
|
|
1
|
+
import GeoJSON, { Geometry } from "geojson";
|
|
3
2
|
/**
|
|
4
3
|
* Geometry type selector for conversions. Use `auto` to try higher dimensions first.
|
|
5
4
|
*/
|
|
@@ -12,8 +11,15 @@ export declare enum GeomType {
|
|
|
12
11
|
multiLineString = 5,
|
|
13
12
|
auto = "auto"
|
|
14
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* geo プラグインが ansuko に追加するメソッド群。
|
|
16
|
+
*
|
|
17
|
+
* このインターフェースは下記の `declare module` ブロックで `AnsukoType` に merge され、
|
|
18
|
+
* `import "ansuko/plugins/geo"` するだけで `_` の型が自動的に拡張される。
|
|
19
|
+
*/
|
|
15
20
|
export interface AnsukoGeoPluginExtension {
|
|
16
21
|
toLngLatArray: (coord: any, digit?: number) => [lng: number, lat: number] | null;
|
|
22
|
+
toGeoJson: (geo: any, type?: GeomType, digit?: number) => Geometry | null;
|
|
17
23
|
toPointGeoJson: (geo: any, digit?: number) => GeoJSON.Point | null;
|
|
18
24
|
toPolygonGeoJson: (geo: any, digit?: number) => GeoJSON.Polygon | null;
|
|
19
25
|
toLineStringGeoJson: (geo: any, digit?: number) => GeoJSON.LineString | null;
|
|
@@ -21,8 +27,12 @@ export interface AnsukoGeoPluginExtension {
|
|
|
21
27
|
toMultiPolygonGeoJson: (geo: any, digit?: number) => GeoJSON.MultiPolygon | null;
|
|
22
28
|
toMultiLineStringGeoJson: (geo: any, digit?: number) => GeoJSON.MultiLineString | null;
|
|
23
29
|
unionPolygon: (geo: any, digit?: number) => GeoJSON.Polygon | GeoJSON.MultiPolygon | null;
|
|
30
|
+
parseToTerraDraw: (geo: any) => GeoJSON.Feature[];
|
|
24
31
|
mZoomInterpolate: (zoomValues: Record<number, number>, type?: string) => any;
|
|
25
32
|
mProps: (properties: Record<string, any>, excludeKeys?: string[]) => Record<string, any>;
|
|
26
33
|
}
|
|
27
|
-
declare
|
|
28
|
-
|
|
34
|
+
declare module "../index.js" {
|
|
35
|
+
interface AnsukoType extends AnsukoGeoPluginExtension {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {};
|
package/dist/plugins/geo.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as turf from "@turf/turf";
|
|
2
|
+
import _ from "../index.js";
|
|
2
3
|
/**
|
|
3
4
|
* Geometry type selector for conversions. Use `auto` to try higher dimensions first.
|
|
4
5
|
*/
|
|
@@ -12,8 +13,9 @@ export var GeomType;
|
|
|
12
13
|
GeomType[GeomType["multiLineString"] = 5] = "multiLineString";
|
|
13
14
|
GeomType["auto"] = "auto";
|
|
14
15
|
})(GeomType || (GeomType = {}));
|
|
15
|
-
const
|
|
16
|
-
|
|
16
|
+
const PLUGIN_NAME = "geo";
|
|
17
|
+
if (!_.__plugins.has(PLUGIN_NAME)) {
|
|
18
|
+
_.__plugins.add(PLUGIN_NAME);
|
|
17
19
|
/**
|
|
18
20
|
* Converts a coordinate-like value to a [lng, lat] tuple, optionally rounding digits.
|
|
19
21
|
* Swaps order if lat/lng appear to be inverted. Returns null when invalid.
|
|
@@ -653,7 +655,7 @@ const ansukoGeoPlugin = (ansuko) => {
|
|
|
653
655
|
}
|
|
654
656
|
return properties;
|
|
655
657
|
};
|
|
656
|
-
const a =
|
|
658
|
+
const a = _;
|
|
657
659
|
a.toLngLatArray = toLngLatArray;
|
|
658
660
|
a.toGeoJson = toGeoJson;
|
|
659
661
|
a.toPointGeoJson = toPointGeoJson;
|
|
@@ -666,6 +668,4 @@ const ansukoGeoPlugin = (ansuko) => {
|
|
|
666
668
|
a.parseToTerraDraw = parseToTerraDraw;
|
|
667
669
|
a.mZoomInterpolate = mZoomInterpolate;
|
|
668
670
|
a.mProps = mProps;
|
|
669
|
-
|
|
670
|
-
};
|
|
671
|
-
export default ansukoGeoPlugin;
|
|
671
|
+
}
|
package/dist/plugins/ja.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { toHalfWidth as utilToHalfWidth, haifun } from "../util.js";
|
|
2
|
+
/**
|
|
3
|
+
* ja プラグインが ansuko に追加するメソッド群。
|
|
4
|
+
*
|
|
5
|
+
* このインターフェースは下記の `declare module` ブロックで `AnsukoType` に merge され、
|
|
6
|
+
* `import "ansuko/plugins/ja"` するだけで `_` の型が自動的に拡張される。
|
|
7
|
+
*/
|
|
3
8
|
export interface AnsukoJaExtension {
|
|
4
9
|
kanaToFull: (str: unknown) => string | null;
|
|
5
10
|
kanaToHalf: (str: unknown) => string | null;
|
|
6
11
|
kanaToHira: (str: unknown) => string | null;
|
|
7
12
|
hiraToKana: (str: unknown) => string | null;
|
|
8
|
-
toHalfWidth: typeof
|
|
13
|
+
toHalfWidth: typeof utilToHalfWidth;
|
|
9
14
|
toFullWidth: (value: unknown, withHaifun?: string) => string | null;
|
|
10
15
|
haifun: typeof haifun;
|
|
11
16
|
}
|
|
12
|
-
declare
|
|
13
|
-
|
|
17
|
+
declare module "../index.js" {
|
|
18
|
+
interface AnsukoType extends AnsukoJaExtension {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {};
|
package/dist/plugins/ja.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import _ from "../index.js";
|
|
1
2
|
import { haifun } from "../util.js";
|
|
2
|
-
const
|
|
3
|
-
|
|
3
|
+
const PLUGIN_NAME = "ja";
|
|
4
|
+
if (!_.__plugins.has(PLUGIN_NAME)) {
|
|
5
|
+
_.__plugins.add(PLUGIN_NAME);
|
|
4
6
|
const kanaMap = {
|
|
5
7
|
'ガ': 'ガ', 'ギ': 'ギ', 'グ': 'グ', 'ゲ': 'ゲ', 'ゴ': 'ゴ',
|
|
6
8
|
'ザ': 'ザ', 'ジ': 'ジ', 'ズ': 'ズ', 'ゼ': 'ゼ', 'ゾ': 'ゾ',
|
|
@@ -64,7 +66,7 @@ const ansukoJaPlugin = (ansuko) => {
|
|
|
64
66
|
if (!_.isValidStr(str)) {
|
|
65
67
|
return null;
|
|
66
68
|
}
|
|
67
|
-
return kanaToFull(str)?.replace(/[
|
|
69
|
+
return kanaToFull(str)?.replace(/[ァ-ヶ]/g, s => String.fromCharCode(s.charCodeAt(0) - 0x60)) ?? null;
|
|
68
70
|
};
|
|
69
71
|
/**
|
|
70
72
|
* Converts hiragana to katakana.
|
|
@@ -77,7 +79,7 @@ const ansukoJaPlugin = (ansuko) => {
|
|
|
77
79
|
if (!_.isValidStr(str)) {
|
|
78
80
|
return null;
|
|
79
81
|
}
|
|
80
|
-
return str.replace(/[
|
|
82
|
+
return str.replace(/[ぁ-ゖ]/g, s => String.fromCharCode(s.charCodeAt(0) + 0x60)) ?? null;
|
|
81
83
|
};
|
|
82
84
|
/**
|
|
83
85
|
* Converts half-width characters to full-width; optionally normalizes hyphens.
|
|
@@ -99,7 +101,7 @@ const ansukoJaPlugin = (ansuko) => {
|
|
|
99
101
|
const code = char.charCodeAt(0);
|
|
100
102
|
// スペース
|
|
101
103
|
if (code === 0x0020) {
|
|
102
|
-
return '
|
|
104
|
+
return ' '; // 全角スペース
|
|
103
105
|
}
|
|
104
106
|
// 全角は0x0021~0x007E、半角は0xFF01~0xFF5E
|
|
105
107
|
if (code >= 0x0021 && code <= 0x007E) {
|
|
@@ -126,7 +128,7 @@ const ansukoJaPlugin = (ansuko) => {
|
|
|
126
128
|
const code = char.charCodeAt(0);
|
|
127
129
|
// スペース
|
|
128
130
|
if (code === 0x3000) {
|
|
129
|
-
return '
|
|
131
|
+
return ' '; // 半角スペース
|
|
130
132
|
}
|
|
131
133
|
// 全角は0xFF01~0xFF5E、半角は0x0021~0x007E
|
|
132
134
|
if (code >= 0xFF01 && code <= 0xFF5E) {
|
|
@@ -136,7 +138,7 @@ const ansukoJaPlugin = (ansuko) => {
|
|
|
136
138
|
}).join('');
|
|
137
139
|
return withHaifun ? haifun(str, withHaifun) : str;
|
|
138
140
|
};
|
|
139
|
-
const a =
|
|
141
|
+
const a = _;
|
|
140
142
|
a.kanaToFull = kanaToFull;
|
|
141
143
|
a.kanaToHalf = kanaToHalf;
|
|
142
144
|
a.kanaToHira = kanaToHira;
|
|
@@ -144,6 +146,4 @@ const ansukoJaPlugin = (ansuko) => {
|
|
|
144
146
|
a.toHalfWidth = toHalfWidth;
|
|
145
147
|
a.toFullWidth = toFullWidth;
|
|
146
148
|
a.haifun = haifun;
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
export default ansukoJaPlugin;
|
|
149
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import _ from "../index.js";
|
|
2
|
+
const PLUGIN_NAME = "prototype";
|
|
3
|
+
if (!_.__plugins.has(PLUGIN_NAME)) {
|
|
4
|
+
_.__plugins.add(PLUGIN_NAME);
|
|
2
5
|
Array.prototype.notMap = function (predicate) {
|
|
3
|
-
return this.map(
|
|
6
|
+
return this.map(_.negate(predicate));
|
|
4
7
|
};
|
|
5
8
|
Array.prototype.notFilter = function (predicate) {
|
|
6
|
-
return this.filter(
|
|
9
|
+
return this.filter(_.negate(predicate));
|
|
7
10
|
};
|
|
8
|
-
}
|
|
9
|
-
export default ansukoPrototypePlugin;
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ansuko",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "A modern JavaScript/TypeScript utility library that extends lodash with practical, intuitive behaviors. Fixes lodash quirks, adds Promise support, Japanese text processing, and GeoJSON utilities.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lodash",
|