@poap-xyz/utils
Advanced tools
Comparing version 0.0.32 to 0.0.33
@@ -7,1 +7,2 @@ export { Chain } from './types/chain'; | ||
export { nextCursor } from './functions/nextCursor'; | ||
export { filterUndefinedProperties, creatUndefinedOrder, createFilter, creatEqFilter, creatNeqFilter, filterZeroAddress, creatAddressFilter, createInFilter, createBetweenFilter, } from './queries/utils'; |
@@ -7,1 +7,2 @@ export { Chain } from './types/chain'; | ||
export { nextCursor } from './functions/nextCursor'; | ||
export { filterUndefinedProperties, creatUndefinedOrder, createFilter, creatEqFilter, creatNeqFilter, filterZeroAddress, creatAddressFilter, createInFilter, createBetweenFilter, } from './queries/utils'; |
@@ -7,1 +7,2 @@ export { Chain } from './types/chain'; | ||
export { nextCursor } from './functions/nextCursor'; | ||
export { filterUndefinedProperties, creatUndefinedOrder, createFilter, creatEqFilter, creatNeqFilter, filterZeroAddress, creatAddressFilter, createInFilter, createBetweenFilter, } from './queries/utils'; |
@@ -31,3 +31,61 @@ (function (global, factory) { | ||
function filterUndefinedProperties(obj) { | ||
const filteredObj = {}; | ||
for (const key in obj) { | ||
if (obj[key] !== undefined) { | ||
filteredObj[key] = obj[key]; | ||
} | ||
} | ||
return filteredObj; | ||
} | ||
function creatUndefinedOrder(key, value) { | ||
return key && value ? { [key]: value } : {}; | ||
} | ||
function createFilter(key, value) { | ||
return value ? { [key]: { _ilike: `%${value}%` } } : {}; | ||
} | ||
function creatEqFilter(key, value) { | ||
return value ? { [key]: { _eq: value } } : {}; | ||
} | ||
function creatNeqFilter(key, value) { | ||
return value ? { [key]: { _neq: value } } : {}; | ||
} | ||
function filterZeroAddress(filter) { | ||
return filter ? { _neq: '0x0000000000000000000000000000000000000000' } : {}; | ||
} | ||
function creatAddressFilter(key, filter, value) { | ||
const addressFilter = { | ||
[key]: { | ||
...filterZeroAddress(filter), | ||
}, | ||
}; | ||
if (value) { | ||
addressFilter[key]._eq = value.toLocaleLowerCase(); | ||
} | ||
return filter || value ? addressFilter : {}; | ||
} | ||
function createInFilter(key, values) { | ||
return values && values.length ? { [key]: { _in: values } } : {}; | ||
} | ||
function createBetweenFilter(key, from, to) { | ||
const dateFilter = {}; | ||
if (from) { | ||
dateFilter._gte = from; | ||
} | ||
if (to) { | ||
dateFilter._lte = to; | ||
} | ||
return from || to ? { [key]: dateFilter } : {}; | ||
} | ||
exports.PaginatedResult = PaginatedResult; | ||
exports.creatAddressFilter = creatAddressFilter; | ||
exports.creatEqFilter = creatEqFilter; | ||
exports.creatNeqFilter = creatNeqFilter; | ||
exports.creatUndefinedOrder = creatUndefinedOrder; | ||
exports.createBetweenFilter = createBetweenFilter; | ||
exports.createFilter = createFilter; | ||
exports.createInFilter = createInFilter; | ||
exports.filterUndefinedProperties = filterUndefinedProperties; | ||
exports.filterZeroAddress = filterZeroAddress; | ||
exports.nextCursor = nextCursor; | ||
@@ -34,0 +92,0 @@ |
{ | ||
"name": "@poap-xyz/utils", | ||
"version": "0.0.32", | ||
"version": "0.0.33", | ||
"description": "Utils module for the poap.js library", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
33734
32
348