import { SUSHInfo } from 'sush';

export interface TrimIdParams {
  head?: number;
  tail?: number;
}

/**
 * `SUSHPluginTrimId` trims head or tail from ID.
 */
function SUSHPluginTrimId (
  { head, tail }: TrimIdParams = { head: 0, tail: 0 }
) {
  return ({ id, stock }: SUSHInfo) => {
    const newId = (!tail) ? id.slice(head) : id.slice(head, -1 * tail);
    return { id: newId, stock } as SUSHInfo;
  };
};

export default SUSHPluginTrimId;

import { SUSHInfo } from 'sush';

export interface TrimIdParams {
  head?: number;
  tail?: number;
}

/**
 * `SUSHPluginTrimId` trims head or tail from ID.
 */
function SUSHPluginTrimId (
  { head = 0, tail = 0 }: TrimIdParams = {}
) {
  return ({ id, stock }: SUSHInfo) => {
    const newId = (!tail) ? id.slice(head) : id.slice(head, -1 * tail);
    return { id: newId, stock } as SUSHInfo;
  };
};

export default SUSHPluginTrimId;

Change default params for plugin
fix: Change default params for plugin

affects: sush-plugin-trim-id
