
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
mock-table-data
Advanced tools
`mock-table-data`는 JavaScript/TypeScript 환경에서 테이블 형태의 데이터를 조건, 정렬, 페이징 기반으로 필터링하거나 가공할 수 있는 유틸리티 클래스입니다. 테스트용 또는 실제 클라이언트 필터링 용도로 사용할 수 있습니다.
mock-table-data
는 JavaScript/TypeScript 환경에서 테이블 형태의 데이터를 조건, 정렬, 페이징 기반으로 필터링하거나 가공할 수 있는 유틸리티 클래스입니다. 테스트용 또는 실제 클라이언트 필터링 용도로 사용할 수 있습니다.
npm install mock-table-data
또는
yarn add mock-table-data
import TableData from 'mock-table-data';
const table = new TableData(dataSource, {
primaryKey: 'id', // 선택사항
dataProcessing: (data) => data.map(row => ({ ...row })) // 선택사항
});
const filtered = table.filteredList([
{ name: 'John', type: 'string', like: true },
{ age: 30, type: 'number' }
]);
const sorted = table.sortedList(filtered, ['name:asc']);
const paged = table.selectRows(10, 0, filtered, ['age:desc'], true);
constructor(dataSource, options?)
dataSource
: 객체 배열 (원본 데이터)options.primaryKey
: 고유 키로 사용할 컬럼명 (중복 삽입 방지)options.dataProcessing
: 최종 데이터 처리 콜백filteredList(conditions)
sortedList(rows, sorts)
sorts
: ['key:asc', 'key2:desc']
형식selectRows(limit?, offset?, conditions?, sort?, meta?)
meta = true
일 경우 { result, meta }
반환insertRow(item)
primaryKey
중복 검사 후 삽입updateRow(conditions, newItem?)
deleteRow(conditions)
selectRow(conditions)
type ConditionItem = {
[key: string]: any;
type?: 'string' | 'number' | 'boolean';
required?: boolean;
like?: boolean;
};
like
: 부분일치 (includes
) 검색required
: 필수값 여부type
: 타입 검사 수행 여부type ConditionNode =
| { logic?: 'AND' | 'OR'; conditions: ConditionNode[] }
| ConditionItem;
복합 조건을 AND
또는 OR
로 구성할 수 있습니다.
const table = new TableData([
{ id: 1, name: 'Alice', age: 25 },
{ id: 2, name: 'Bob', age: 30 }
]);
const result = table.selectRows(10, 0, [
{ name: 'ali', type: 'string', like: true }
]);
console.log(result);
const table = new TableData([
{ id: 1, name: 'Alice', role: 'admin' },
{ id: 2, name: 'Bob', role: 'user' },
{ id: 3, name: 'Charlie', role: 'guest' }
]);
const result = table.selectRows(10, 0, {
logic: 'OR',
conditions: [
{ role: 'admin' },
{ role: 'guest' }
]
});
console.log(result);
// 결과: Alice 와 Charlie의 데이터가 반환됩니다.
ISC
FAQs
`mock-table-data`는 JavaScript/TypeScript 환경에서 테이블 형태의 데이터를 조건, 정렬, 페이징 기반으로 필터링하거나 가공할 수 있는 유틸리티 클래스입니다. 테스트용 또는 실제 클라이언트 필터링 용도로 사용할 수 있습니다.
We found that mock-table-data demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.