> For the complete documentation index, see [llms.txt](https://ddzy.gitbook.io/ts-utility-plugins-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ddzy.gitbook.io/ts-utility-plugins-docs/utility/utility-array/pullall.md).

# pullAll

### 说明

&#x20;移除数组 `arr` 中所有和给定值相等的元素, 原地操作

### 源码

<https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/array/pullAll>

### 用法

{% code title="pullAll.test.ts" %}

```typescript
import { pullAll } from "../../utility/array/pullAll";


describe('pullAll tests...', () => {
  test('Method pullAll should receive an array composed of number and return the filtered array', () => {
    const received = {
      origin: [1, 2, 3, 1, 2, 3],
      selector: [2, 3],
    };
    const expected = {
      isEqual: true,
      result: [1, 1],
    };

    const result = pullAll<number>(received.origin, received.selector);

    expect(result === received.origin).toBe(expected.isEqual);

    result.forEach((v, i) => {
      expect(v).toBe(expected.result[i]);
    });
  });

  test('Method pullAll should receive an array composed of plain object and return the filtered array', () => {
    interface IOriginParams {
      name: string,
      age: number,
    };

    const received = {
      origin: [
        {
          name: 'duan',
          age: 21,
        },
        {
          name: 'zhao',
          age: 22,
        },
        {
          name: 'duan',
          age: 21,
        },
      ],
      selector: [
        {
          name: 'duan',
          age: 21,
        },
      ],
    };
    const expected = {
      isEqual: true,
      result: [
        {
          name: 'duan',
          age: 21,
        },
        {
          name: 'zhao',
          age: 22,
        },
        {
          name: 'duan',
          age: 21,
        },
      ],
    };

    const result = pullAll<IOriginParams>(received.origin, received.selector);

    expect(result === received.origin).toBe(expected.isEqual);

    expect(result.length).toBe(expected.result.length);
  });

  test('Method pullAll should receive an array composed of mixed value and return the filtered array', () => {
    const received = {
      origin: [
        0,
        19980808,
        'duanzhaoyang',
        false,
        null,
        undefined,
        Symbol('a'),
        function () { },
        {},
        [],
      ],
      selector: [false, undefined, 19980808, []],
    };
    const expected = {
      isEqual: true,
      result: [
        0,
        'duanzhaoyang',
        null,
        Symbol('a'),
        function () { },
        {},
        [],
      ],
    };

    const result = pullAll<any>(received.origin, received.selector);

    expect(result === received.origin).toBe(expected.isEqual);

    expect(result.length).toBe(expected.result.length);
  });
});
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ddzy.gitbook.io/ts-utility-plugins-docs/utility/utility-array/pullall.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
