then / is-promise Goto Github PK
View Code? Open in Web Editor NEWTest whether an object looks like a promises-a+ promise
License: MIT License
Test whether an object looks like a promises-a+ promise
License: MIT License
Just got caught up using is-promise
with a jQuery.Deferred as then
is defined but catch
is not. Since this is is-promise
and not is-thenable
I figured it might be a good idea to check catch
as well.
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function' && typeof obj.catch === 'function';
npx create-react-app test
npx: installed 99 in 6.053s
Must use import to load ES Module: /Users/<REDACTED>/.npm/_npx/93178/lib/node_modules/create-react-app/node_modules/is-promise/index.js
require() of ES modules is not supported.
require() of /Users/<REDACTED>/.npm/_npx/93178/lib/node_modules/create-react-app/node_modules/is-promise/index.js from /Users/<REDACTED>/.npm/_npx/93178/lib/node_modules/create-react-app/node_modules/run-async/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /Users/<REDACTED>/.npm/_npx/93178/lib/node_modules/create-react-app/node_modules/is-promise/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /Users/<REDACTED>/.npm/_npx/93178/lib/node_modules/create-react-app/node_modules/is-promise/package.json.```
When I run a React Native app, the following warning appear in the console.
Someone know what is this?
Package is-promise has been ignored because it contains invalid configuration.
Reason: Package subpath './package.json' is not defined by "exports" in node_modules/is-promise/package.json
Why use one line of code in the form of a separate library by creating a dependency graph, increasing the build time of the project. What is this trend?
I don't think this is a very useful snippet, sorry.
console.log(isPromise({then: () => {}}));
I used:
npx create-react-app userbase
to create my react app but I got some weird error
internal/modules/cjs/loader.js:1173
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: C:\Users\yoges\AppData\Roaming\npm\node_modules\create-react-app\node_modules\is-promise\index.js
require() of ES modules is not supported.
require() of C:\Users\yoges\AppData\Roaming\npm\node_modules\create-react-app\node_modules\is-promise\index.js from C:\Users\yoges\AppData\Roaming\npm\node_modules\create-react-app\node_modules\run-async\index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename C:\Users\yoges\AppData\Roaming\npm\node_modules\create-react-app\node_modules\is-promise\index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from C:\Users\yoges\AppData\Roaming\npm\node_modules\create-react-app\node_modules\is-promise\package.json.
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1173:13)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14)
at Module.require (internal/modules/cjs/loader.js:1043:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\yoges\AppData\Roaming\npm\node_modules\create-react-app\node_modules\run-async\index.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14) {
code: 'ERR_REQUIRE_ESM'
}
How can I solve this?!
Issue: There is no package-lock.json or npm-shrinkwrap.json file uploaded to the GitHub repository https://github.com/then/is-promise
Questions: We are conducting a research study on the lock files used in JS projects. We were curious:
For any publication or research report based on this study, we will share all responses from developers in an anonymous way. Both your projects and personal information will be kept confidential.
Rationale: NPM introduced package-lock.json and npm-shrimpwrap.json files to capture the exact dependency tree installed at any point in time. When package.json defines the required dependencies and their respective versions using semantic versioning (e.g., “express”: “^4.16.4”), npm always downloads the latest version of packages to satisfy the specified version ranges (e.g., 4.17.1)[1]. If the latest version of any package keeps changing and has backward incompatibility issues with previous versions, the project may have an inconsistent running environment and get intermittent failures. In such scenarios, it can be very difficult for developers to debug programs and settle down the software environment [2].
List of Risks:
Suggested Solution: Please fixate the dependencies by either specifying the exact library version in the package.json file or by uploading the package-lock.json or npm-shrinkwrap.json file to GitHub.
References:
https://docs.npmjs.com/cli/v7/configuring-npm/package-lock-json
https://blog.logrocket.com/why-you-should-use-package-lock-json/
2019. 10 npm Security Best Practices. https://snyk.io/blog/ten-npm-security-best-practices/.
Pronnoy Goswami, Saksham Gupta, Zhiyuan Li, Na Meng, and Daphne Yao. 2020. Investigating The Reproducibility of NPM Packages. In2020 IEEE International
2021. Npm Security Best Practices. https://bytesafe.dev/posts/npm-security-best-practices/#no9-deterministic-results.
I'm getting a failure on a Travis build from this update. Looks like you just added a dual-module package. With type: module
in the package.json, I think main
should point to the ESM build or needs the .cjs
extension.
Build is here: https://travis-ci.org/github/mAAdhaTTah/brookjs/jobs/679426871
I haven't written a dual module package, so I could be wrong on the fix, but the current implementation is def broken, unfortunately.
The guard should use PromiseLike<T>
, not Promise<T>
.
If a thenable can be considered a Promise/A+ promise ("if it looks like a duck, it is a duck"), it certainly does not means it's also a ES Promise (which also has catch
and finally
).
Therefore the PromiseLike
in TypeScript.
@ForbesLindesay I am pleased to see that you recently added a type definition for isPromise()
, but unfortunately, it seems you forgot to include it in the published package. Could you add it, please?
The module fails to import with node v13.12.0
. The version 2.1.0 still works fine.
sorunome@sorunome-desktop repos/mx-puppet-skype $ node ./build/index.js 1
internal/modules/cjs/loader.js:616
if (e.code !== 'ERR_PACKAGE_PATH_NOT_EXPORTED') throw e;
^
Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "index.js" defined in the package config /home/sorunome/repos/mx-puppet-skype/node_modules/is-promise/package.json
at resolveExportsTarget (internal/modules/cjs/loader.js:574:13)
at resolveExportsTarget (internal/modules/cjs/loader.js:613:20)
at applyExports (internal/modules/cjs/loader.js:503:14)
at resolveExports (internal/modules/cjs/loader.js:541:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:661:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27)
at Function.Module._load (internal/modules/cjs/loader.js:859:27)
at Module.require (internal/modules/cjs/loader.js:1036:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/sorunome/repos/mx-puppet-skype/node_modules/lowdb/lib/main.js:4:17) {
code: 'ERR_INVALID_PACKAGE_TARGET'
}
This error is displayed in node 13.13.0, when the package is-promise (v 2.2.0) is loaded
Hey,
I see a commit message for the stricter test, but it's not clear why's that extra processing good. Perhaps you can share some light. Thanks!
Adding "exports" is a breaking change, and should not have happened in v2.2.0. Please release a new v2 that does not have "exports" and does not use type:module or ESM, and then rerelease as v3.
Package with dependency on is-promise (svelte-forms) during build with rollout throws:
[rollup-plugin-svelte] The following packages did not export their package.json
file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file.
Hi everyone
Bear with me, this is the first time I open up an issue as a junior developer. I'm trying to create a Nuxt.js website but when I try to create it, it fails and your module has something to do with it.
Are you guys aware of the issue or not? Not entirely sure if this is the way to address this issue since it's Nuxt.js related but I think this module is causing the failure.
Sorry if this has been submitted in the wrong place. Then just delete it but maybe this will get me more answers 😅
Please comment on this issue if you are still experiencing issues wen upgrading to 2.2.1
An object with [[IsHTMLDDA]] internal slot that happen to have callable then
property won't be reported as a promise, even if the ECMAScript considers such objects to be promises.
As the title goes...
is-promise
Unknown error: Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/runner/work/codeJunction-site/codeJunction-site/node_modules/is-promise/index.js
require() of ES modules is not supported.
require() of /home/runner/work/codeJunction-site/codeJunction-site/node_modules/is-promise/index.js from /home/runner/work/codeJunction-site/codeJunction-
This module is just ridiculous. The existence of "libraries" like this compromises the consistency and long-term viability of the JS ecosystem. This should not exist.
Would it be possible to include a LICENSE file with the text of the license agreement?
Our lawyers are saying that just having "License: MIT" is not sufficient.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.