Coder Social home page Coder Social logo

iso-639-1's Issues

Error in dependencies

Error: Cannot find module 'babel-runtime/core-js/object/keys'
    at Function.Module._resolveFilename (module.js:472:15)

BTW if you're making some serious changes it's better and safer to update major version or at least minor, but not patch.

Types are not exported

I get this error with the new version:

main.js:1:21 - error TS7016: Could not find a declaration file for module 'iso-639-1'. '/private/tmp/iso-bug/node_modules/iso-639-1/src/wrapper.mjs' implicitly has an 'any' type.
  There are types at '/private/tmp/iso-bug/node_modules/iso-639-1/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'iso-639-1' library may need to update its package.json or typings.

1 import ISO6391 from "iso-639-1";

I believe you need to add types/default fields since the types are at a different location (index.d.ts while the file is at src/wrapper.mjs). More information here.

To reproduce the issue:

main.js:

import ISO6391 from "iso-639-1";

jsconfig.json:

{
  "compilerOptions": {
    "checkJs": true,
    "target": "ES2022",
    "module": "Node16",
    "maxNodeModuleJsDepth": 0,
    "strict": true
  }
}

package.json:

{
  "type": "module",
  "scripts": {
    "typecheck": "tsc -p jsconfig.json"
  },
  "dependencies": {
    "iso-639-1": "^3.0.0"
  },
  "devDependencies": {
    "typescript": "^5.1.6"
  }
}

Command: npm run typecheck

Changelog?

Do you have a changelog? It would be nice to have some context for upgrades to make sure they are well tested.

Importing all of babel-polyfill leads to large bundle sizes

In index.js, the require('babel-polyfill') pulls in all of babel-polyfill. That leads to a huge amount of polyfills being brought in for a small library. In my webpack output, iso-639-1 is less than 10kb, and there was at least 100kb worth of polyfills being brought in because of babel-polyfill.

.validate behaves incorrectly for prototype property names as code

The core ISO6391.validate method behaves incorrectly for prototype property names provided as code parameters, e.g. "toString".

const ISO6391 = require('iso-639-1')
it('toString', function() {
  assert.equal(ISO6391.validate('toString'), false);  // fails: returns `true` unexpectedly
});

Incorrect typing.

The function returns an empty string '' when there is no match but the TypeScript signature doesn't include this type.

ChainAlert: npm package release (2.1.14) has no matching tag in this repo

Dear iso-639-1 maintainers,
Thank you for your contribution to the open-source community.

This issue was automatically created to inform you a new version (2.1.14) of iso-639-1 was published without a matching tag in this repo.

As part of our efforts to fight software supply chain attacks, we would like to verify this release is known and intended, and not a result of an unauthorized activity.

If you find this behavior legitimate, kindly close and ignore this issue. Read more

badge

ISO6391 ES6 import undefined

image

I Imported the library in the file but it always returns undefined

import {
  registerDecorator,
  ValidationOptions,
  // ValidationArguments,
} from 'class-validator';
import ISO6391 from 'iso-639-1';

export function IsISO6391(
  validationOptions?: ValidationOptions,
): PropertyDecorator {
  return function (object: object, propertyName: string) {
    registerDecorator({
      name: 'IsISO6391',
      target: object.constructor,
      propertyName: propertyName,
      options: validationOptions,
      validator: {
        validate(value: any) {
          console.log(ISO6391);
          return (
            typeof value === 'string' &&
            ISO6391.validate(String(value.toLocaleLowerCase()))
          );
          // you can return a Promise<boolean> here as well, if you want to make async validation
        },
      },
    });
  };
}

import as ES module give me an undefined object

When I import this module using the next code

import ISO6391 from 'iso-639-1';
console.log(ISO6391.getAllCodes());

I've got the error "Cannot read properties of undefined (reading 'getAllCodes')" however, if I import it using require all works fine, but, it is not normal to have code like this, it is not harmonics.

import { Injectable } from '@nestjs/common';
import { CreateLanguageDto } from './dto/create-language.dto';
import { UpdateLanguageDto } from './dto/update-language.dto';
const ISO6391 = require('iso-639-1'); //import is not working

Could you fix this please ?

validate fn expecting LanguageCode instead string

Hi!

error TS2345: Argument of type 'string' is not assignable to parameter of type 'LanguageCode'.

Even in documentation validate is defined as receiving a string, the interface defined in index.d.ts expects a LanguageCode.
(Also happening for the rest of functions)

How about iso-639-2 languages?

I have run into an issue where most things work fine.
But use case needs to support 639-2 language is there any extension to this library or can I raise PR including that language.

License is missing

Hey,
I noticed that the repository does not include a License file. This is a problem since in many jurisdictions the author retains all rights pertaining to his work (incl. usage elsewhere as a dependancy) unless explicitly stated otherwise. This makes adoption of or contribution to this package difficult.

Please consider adding a license. If you are not sure about what to pick, there are great resources for that out there!

Have a great day!

getCode() with not supported language name

Unlike getName() that returns an empty string when called with a non-ISO language code, getCode() throws an exception when called with a non-canonical, misspelled or inexistent language name:
iso.getCode('Tibetan'); // supposed to be Tibetan Standard...

~/project/node_modules/babel-runtime/helpers/slicedToArray.js:48
      throw new TypeError("Invalid attempt to destructure non-iterable instance");
      ^

TypeError: Invalid attempt to destructure non-iterable instance
    at ~/project/node_modules/babel-runtime/helpers/slicedToArray.js:48:13
    at Function.ISO6391.getCode (/home/ubuntu/projects/learn_bpe/node_modules/iso-639-1/build/index.js:85:59)
    at Object.<anonymous> (/home/ubuntu/projects/learn_bpe/cli.js:61:17)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)

(node v6.8.1 under ubuntu 14.04)

Error in commonjs

Error

const iso6391 = require('iso-639-1');
iso6391.validate('es');

Good

const iso6391 = require('iso-639-1').default;
iso6391.validate('es');

import { getNativeName, getCode } from "iso-639-1" ; not working after updating webpack 4 version .

I upgraded my webpack version from 1 to 4 and now I get an error using "iso-639-1" lib in {getNativeName ,getCode} while importing .

Error I get "TypeError: (0 , _iso.getNativeName) is not a function”

Note:

  • import { getNativeName, getCode } from "iso-639-1" ; was working fine with webpack 1 version and not able to import in webpack4.
  • have also updated iso-639-1 lib to latest "2.1.0" version and tested.

I was able to fix doing the below code snippet for webpack 4

const ISO6391 = require("iso-639-1");

const getNativeName = ISO6391.default.getNativeName;
const getCode = ISO6391.default.getCode;

but i am not confident about this fix .
Can you please help here for a proper fix ? Looks like this doesn't have proper ES modules support .

Support three letter codes

Would it be possible to add three letter codes ? There are some downstream apps (e.g. Mozilla's voice-web) that would benefit from it. I can make an initial pull request (see #16).

Usage with TypeScript

The typing information states that I should use a default export:

import iso6391 from 'iso-639-1'

Accessing (for example) iso6391.getAllCode works according to typescript, but iso6391 is actually undefined. It seems like it's actually a namespace import:

import * as iso6391 from 'iso-639-1'

Now TypeScript breaks, but the runtime code works.

My current workaround is:

import * as _iso6391 from 'iso-639-1'
const iso6391 = _iso6391 as any as typeof import('iso-639-1').default

Not sure if this has something to do with the allowSyntheticDefaultImports option which I have set to true, but I know it fiddles with namespace vs default imports... 🤔

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.