Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// @flow
//
// Copyright (c) 2018-present, Cruise LLC
//
// This source code is licensed under the Apache License, Version 2.0,
// found in the LICENSE file in the root directory of this source tree.
// You may not use this file except in compliance with the License.
import natsort from "natsort";
const sortFn = natsort({ insensitive: true });
export default function naturalSort(key?: string) {
return key ? (a: any, b: any) => sortFn(a[key], b[key]) : sortFn;
}
import R from 'ramda';
import natsort from 'natsort';
const sortObjects = natsort();
/**
* Sort an array of objects by property.
*
* @param {String|Array} prop
* A property to sort by. If passed as an array, it
* will be treated as a deep property path.
*
* @param {Array} list
* An array of objects to sort.
*
* @return {Array}
* A sorted copy of the passed array.
*
* @example
* sortByProp('order', items);
(): Array => {
const sorter = natsort();
return cloneDeep(props.value.concat(available.value)).sort((a: TemplateVariable, b: TemplateVariable) =>
sorter(a.name, b.name),
);
},
);
'use strict'
const fs = require('mz/fs')
const natsort = require('natsort').default({insensitive: true})
const file = require('random-access-file')
const isDir = (dir) =>
fs.stat(dir)
.then((s) => s.isDirectory())
const sortFiles = (fileA, fileB) => {
if (fileA.isDir && !fileB.isDir) return -1
if (fileB.isDir && !fileA.isDir) return 1
return natsort(fileA.name, fileB.name)
}
const slice = (path, bytes, offset = 0) => {
return fs.stat(path)