@@ -85,12 +85,11 @@ function normalise(input) {
85
85
return input . replace ( / _ / , '-' ) ;
86
86
}
87
87
88
- // Uses a map as a simple memoization technique without having to import `mem`
89
- const asyncCache = new Map ( ) ;
88
+ const cache = new Map ( ) ;
90
89
91
90
module . exports = async ( options = defaultOptions ) => {
92
- if ( asyncCache . has ( options . spawn ) ) {
93
- return asyncCache . get ( options . spawn ) ;
91
+ if ( cache . has ( options . spawn ) ) {
92
+ return cache . get ( options . spawn ) ;
94
93
}
95
94
96
95
let locale ;
@@ -110,15 +109,13 @@ module.exports = async (options = defaultOptions) => {
110
109
} catch { }
111
110
112
111
const normalised = normalise ( locale || defaultLocale ) ;
113
- asyncCache . set ( options . spawn , normalised ) ;
112
+ cache . set ( options . spawn , normalised ) ;
114
113
return normalised ;
115
114
} ;
116
115
117
- const syncCache = new Map ( ) ;
118
-
119
116
module . exports . sync = ( options = defaultOptions ) => {
120
- if ( syncCache . has ( options . spawn ) ) {
121
- return syncCache . get ( options . spawn ) ;
117
+ if ( cache . has ( options . spawn ) ) {
118
+ return cache . get ( options . spawn ) ;
122
119
}
123
120
124
121
let locale ;
@@ -137,6 +134,6 @@ module.exports.sync = (options = defaultOptions) => {
137
134
} catch { }
138
135
139
136
const normalised = normalise ( locale || defaultLocale ) ;
140
- syncCache . set ( options . spawn , normalised ) ;
137
+ cache . set ( options . spawn , normalised ) ;
141
138
return normalised ;
142
139
} ;
0 commit comments