jorisgp / sort-nested-json

A NPM module for sorting an json array.
MIT License
5 stars 0 forks source link

Sorter is getting undefined in nestjs #7

Closed cs111 closed 1 year ago

cs111 commented 1 year ago

list = [ { id: 1, firstname: "John", lastname: "Smith", }, { id: 2, firstname: "Jane", lastname: "Wilson", }, { id: 3, firstname: "Peter", lastname: "Brown", }, ];

list = sorter.sort(list).desc("firstname");

console.log(list);

response: list = sorter.sort(list).desc("firstname"); ^ source-map-support.js:722 TypeError: Cannot read properties of undefined (reading 'sort')

here is my package.json

{ "name": "247uptime-backend", "version": "0.0.1", "description": "", "author": "247FactoryNet GmbH", "private": true, "license": "UNLICENSED", "scripts": { "build": "nest build", "format": "prettier --write \"src//*.ts\" \"test/*/.ts\"", "start": "nest start", "start:dev": "nest start --watch", "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}//.ts\" --fix", "test": "jest", "test:watch": "jest --watch", "test:cov": "jest --coverage", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", "test:e2e": "jest --config ./test/jest-e2e.json" }, "dependencies": { "@nestjs-modules/mailer": "^1.9.1", "@nestjs/axios": "^3.0.0", "@nestjs/common": "^10.1.3", "@nestjs/config": "^3.0.0", "@nestjs/core": "^10.1.3", "@nestjs/elasticsearch": "^10.0.1", "@nestjs/jwt": "^10.1.0", "@nestjs/microservices": "^10.1.3", "@nestjs/passport": "^10.0.0", "@nestjs/platform-express": "^10.1.3", "@nestjs/platform-socket.io": "^10.2.1", "@nestjs/schedule": "^3.0.2", "@nestjs/swagger": "^7.1.8", "@nestjs/websockets": "^10.1.3", "@nestjsplus/redirect": "^1.0.0", "amqp-connection-manager": "^4.1.14", "amqplib": "^0.10.3", "archiver": "^6.0.0", "axios": "^1.4.0", "class-transformer": "^0.5.1", "class-validator": "^0.14.0", "cookie-parser": "^1.4.6", "dotenv": "^16.3.1", "firebase-admin": "^11.10.1", "moment": "^2.29.4", "nest-winston": "^1.9.3", "otplib": "^12.0.1", "passport-jwt": "^4.0.1", "passport-local": "^1.0.0", "pdf-to-base64": "^1.0.3", "qrcode": "^1.5.3", "reflect-metadata": "^0.1.13", "rxjs": "^7.8.1", "socket.io": "^4.7.2", "sort-nested-json": "^0.4.3", "uuid": "^9.0.0", "winston": "^3.10.0", "winston-transport": "^4.5.0" }, "devDependencies": { "@nestjs/cli": "^10.1.12", "@nestjs/schematics": "^10.0.2", "@nestjs/testing": "^10.1.3", "@types/express": "^4.17.17", "@types/jest": "^29.5.3", "@types/node": "^20.5.1", "@types/supertest": "^2.0.12", "@typescript-eslint/eslint-plugin": "^6.4.0", "@typescript-eslint/parser": "^6.4.0", "eslint": "^8.47.0", "eslint-config-prettier": "^9.0.0", "eslint-plugin-prettier": "^5.0.0", "jest": "^29.6.2", "prettier": "^3.0.2", "source-map-support": "^0.5.21", "supertest": "^6.3.3", "ts-jest": "^29.1.1", "ts-loader": "^9.4.4", "ts-node": "^10.9.1", "tsconfig-paths": "^4.2.0", "typescript": "^5.1.6" }, "jest": { "moduleFileExtensions": [ "js", "json", "ts" ], "rootDir": "src", "testRegex": ".\.spec\.ts$", "transform": { "^.+\.(t|j)s$": "ts-jest" }, "collectCoverageFrom": [ "*/.(t|j)s" ], "coverageDirectory": "../coverage", "testEnvironment": "node" } }

@jorisgp

cs111 commented 1 year ago

import {sort} from 'sort-nested-json'; solved. sorter is not working