MCPcopy Index your code
hub / github.com/nodejs/node / fromJSON

Method fromJSON

lib/internal/blocklist.js:242–266  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

240 }
241
242 fromJSON(data) {
243 // The data argument must be a string, or an array of strings that
244 // is JSON parseable.
245 if (ArrayIsArray(data)) {
246 for (const n of data) {
247 if (typeof n !== 'string') {
248 throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
249 }
250 }
251 } else if (typeof data !== 'string') {
252 throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
253 } else {
254 data = JSONParse(data);
255 if (!ArrayIsArray(data)) {
256 throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
257 }
258 for (const n of data) {
259 if (typeof n !== 'string') {
260 throw new ERR_INVALID_ARG_TYPE('data', ['string', 'string[]'], data);
261 }
262 }
263 }
264
265 this.#parseIPInfo(data);
266 }
267
268
269 get rules() {

Callers 1

test-blocklist.jsFile · 0.80

Calls 1

#parseIPInfoMethod · 0.95

Tested by

no test coverage detected