Comparing version 1.0.1 to 1.0.2
@@ -116,15 +116,12 @@ "use strict"; | ||
]; | ||
// Types can come from DT or be bundled. We're never interested in @types packages themselves. | ||
var IS_DT = 'types.ts:"definitely-typed"'; | ||
var IS_INCLUDED = 'types.ts:"included"'; | ||
var NOT_TYPES = 'NOT owner.name:DefinitelyTyped'; | ||
var FILTERS = { | ||
default: 'types.ts:"definitely-typed" OR types.ts:"included"', | ||
dt: 'types.ts:"definitely-typed"', | ||
bundled: 'types.ts:"included"', | ||
default: "(" + IS_DT + " OR " + IS_INCLUDED + ") AND " + NOT_TYPES, | ||
dt: IS_DT, | ||
bundled: IS_INCLUDED + " AND " + NOT_TYPES, | ||
untyped: NOT_TYPES, | ||
}; | ||
var PARAMS = { | ||
hitsPerPage: 20, | ||
filters: FILTERS.default, | ||
attributes: ATTRIBUTES.join(','), | ||
'x-algolia-agent': 'Algolia for vanilla JavaScript (lite) 3.27.1', | ||
'x-algolia-application-id': 'OFCNCOG2CU', | ||
'x-algolia-api-key': 'f54e21fa3a2a0160595bb058179bfb1e', | ||
}; | ||
var client = algoliasearch_1.default(key_1.APP_ID, key_1.API_KEY); | ||
@@ -397,3 +394,3 @@ var index = client.initIndex('npm-search'); | ||
if (commander_1.program.untyped) { | ||
filters = undefined; | ||
filters = FILTERS.untyped; | ||
} | ||
@@ -419,3 +416,3 @@ else if (commander_1.program.dt) { | ||
analyticsTags: ['dtsearch'], | ||
hitsPerPage: Math.floor(num * 1.5), | ||
hitsPerPage: num, | ||
filters: filters, | ||
@@ -430,3 +427,3 @@ attributesToRetrieve: ATTRIBUTES, | ||
} | ||
hits = result.hits.filter(function (hit) { return !hit.objectID.startsWith('@types/'); }); | ||
hits = result.hits; | ||
if (hits.length === 0) { | ||
@@ -440,3 +437,2 @@ console.log('No results. Try dtsearch -u to include packages without types.'); | ||
} | ||
hits = hits.slice(0, num); | ||
table = hits.map(formatResult); | ||
@@ -443,0 +439,0 @@ printTable(table, hits); |
{ | ||
"name": "dtsearch", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Find packages with TypeScript types, either bundled or on Definitely Typed", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -37,15 +37,13 @@ import algoliasearch from 'algoliasearch'; | ||
]; | ||
// Types can come from DT or be bundled. We're never interested in @types packages themselves. | ||
const IS_DT = 'types.ts:"definitely-typed"'; | ||
const IS_INCLUDED = 'types.ts:"included"'; | ||
const NOT_TYPES = 'NOT owner.name:DefinitelyTyped'; | ||
const FILTERS = { | ||
default: 'types.ts:"definitely-typed" OR types.ts:"included"', | ||
dt: 'types.ts:"definitely-typed"', | ||
bundled: 'types.ts:"included"', | ||
default: `(${IS_DT} OR ${IS_INCLUDED}) AND ${NOT_TYPES}`, | ||
dt: IS_DT, | ||
bundled: `${IS_INCLUDED} AND ${NOT_TYPES}`, | ||
untyped: NOT_TYPES, | ||
}; | ||
const PARAMS = { | ||
hitsPerPage: 20, | ||
filters: FILTERS.default, | ||
attributes: ATTRIBUTES.join(','), | ||
'x-algolia-agent': 'Algolia for vanilla JavaScript (lite) 3.27.1', | ||
'x-algolia-application-id': 'OFCNCOG2CU', | ||
'x-algolia-api-key': 'f54e21fa3a2a0160595bb058179bfb1e', | ||
}; | ||
@@ -244,3 +242,3 @@ const client = algoliasearch(APP_ID, API_KEY); | ||
function printTable(rows: string[][], hits: Hit[]) { | ||
function printTable(rows: string[][], hits: readonly Hit[]) { | ||
const cols = columns.map((c, j) => [ | ||
@@ -304,3 +302,3 @@ c.header.toUpperCase(), ...rows.map(r => r[j]) | ||
if (program.untyped) { | ||
filters = undefined; | ||
filters = FILTERS.untyped; | ||
} else if (program.dt) { | ||
@@ -325,3 +323,3 @@ filters = FILTERS.dt; | ||
analyticsTags: ['dtsearch'], | ||
hitsPerPage: Math.floor(num * 1.5), // Overfetch a bit in case there are @types results. | ||
hitsPerPage: num, | ||
filters, | ||
@@ -335,3 +333,3 @@ attributesToRetrieve: ATTRIBUTES, | ||
let hits = result.hits.filter(hit => !hit.objectID.startsWith('@types/')); | ||
const {hits} = result; | ||
if (hits.length === 0) { | ||
@@ -347,3 +345,2 @@ console.log('No results. Try dtsearch -u to include packages without types.'); | ||
hits = hits.slice(0, num); | ||
const table = hits.map(formatResult); | ||
@@ -350,0 +347,0 @@ printTable(table, hits); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8722140
901